making server buildable

This commit is contained in:
Chris Cochrun 2023-06-13 07:34:00 -05:00
parent bc15f05603
commit ec3bde1191
6 changed files with 85 additions and 17 deletions

View file

@ -1,14 +1,6 @@
(require :asdf)
(require :hunchentoot)
(require :dexador)
(require :serapeum)
(require :clack)
(require :com.inuoe.jzon)
;; (load "~/quicklisp/setup.lisp")
;; (ql:quickload :cffi :silent t)
;; (ql:quickload '(hunchentoot clack dexador com.inuoe.jzon serapeum))
(ql:quickload '(hunchentoot clack dexador com.inuoe.jzon serapeum bordeaux-threads))
(uiop:define-package tfc-server
(defpackage tfc-server
(:use :cl :uiop :com.inuoe.jzon :clack))
(in-package :tfc-server)
@ -19,7 +11,10 @@
(defvar *stream*)
(defvar *auth-token* "boFFRM68vvXbO-DO7S9YDg86lHX027-hd07mn0dh")
(defvar *server* (hunchentoot:start (make-instance 'hunchentoot:easy-acceptor :port 4242)))
(defvar *server*)
(defun start-server (port)
(setq *server* (hunchentoot:start (make-instance 'hunchentoot:easy-acceptor :port port))))
(defun post-health-form (data-list)
"Takes the health form as an alist and posts it to nocodb"
@ -55,9 +50,9 @@
(defun process-form (form)
"Processes the form and sends it on"
(uiop:println "---")
(maphash 'print-hash-entry form)
(uiop:println "---"))
(uiop:println "---")
(maphash 'print-hash-entry form)
(uiop:println "---"))
(defun save-string-file (string file-path)
"save a file that is represented as a string to disk that came from a multipart/form-data"
@ -86,7 +81,7 @@
(setq *last-list-data* nil)
(loop :for i :in *last-data*
:do (let* ((content-disposition (nth 1
(serapeum:lines i :eol-style :crlf :honor-crlf t)))
(serapeum:lines i :eol-style :crlf :honor-crlf t)))
(start (if content-disposition (position #\" content-disposition)))
(end (if start (position #\" content-disposition :start (1+ start)) nil))
(name (if end (if start (subseq content-disposition (1+ start) end) nil) nil))
@ -136,3 +131,19 @@
(post-health-form *last-list-data*)
(format nil "thankyou"))))))
(defun main ()
(start-server 4242)
(format t "Server has started on port 4242~&")
(handler-case (bt:join-thread (find-if (lambda (th)
(search "hunchentoot" (bt:thread-name th)))
(bt:all-threads)))
(#+sbcl sb-sys:interactive-interrupt
#+ccl ccl:interrupt-signal-condition
#+clisp system::simple-interrupt-condition
#+ecl ext:interactive-interrupt
#+allegro excl:interrupt-signal
() (progn
(format *error-output* "Aborting.~&")
(hunchentoot:stop *server*)
(uiop:quit)))
(error (c) (format t "Woops, an unknown error occured:~&~a~&" c))))

Binary file not shown.

Before

Width:  |  Height:  |  Size: 679 KiB