-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhttpsrv.spad
60 lines (46 loc) · 1.79 KB
/
httpsrv.spad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
)abbrev package HTTPSRV HttpServer
++ Author: Kurt Pagani <nilqed@gmail.com>
++ Date Created: Mon Nov 30 18:54:58 CET 2015
++ Date Revised: Fri Apr 03 01:03:34 CET 2021
++ License: BSD
++ Date Last Updated:
++ Basic Operations:
++ Depends On: HUNCHENTOOT/HTPP-SERVER
++ Examples:
++ References:
++ https://edicl.github.io/hunchentoot/
++ Description:
++ cl-hunchentoot/bionic,bionic,now 1.2.35-1 all [installed]
++ Common Lisp web server formerly known as TBNL
++ sudo apt install cl-hunchentoot
++ Test 'require':
++ rlwrap sbcl
++ * (require :asdf)
++ * (require :hunchentoot)
++
HttpServer() : Exports == Implementation where
STR ==> String
SEX ==> SExpression
MSC ==> MoreSystemCommands
syscmd(s) ==> systemCommand(s)$MSC
lisp1(s) ==> syscmd(string(FORMAT('NIL,"lisp ~A",s)$Lisp))
lisp2(s) ==> syscmd(string(FORMAT('NIL,"lisp ~A ~A",s1,s2)$Lisp))
Exports == with
start : PositiveInteger -> SEX
++ start(p) starts the HTTP server listening on port p.
++ Example: start 4242 => open http://localhost:4242/ in
++ browser.
Implementation == add
lisp1 "(require :asdf)"
lisp1 "(require :hunchentoot)"
lisp1 "(defun |htStart| (p) (hunchentoot:start "_
"(make-instance 'hunchentoot:easy-acceptor :port p)))"
lisp1 "(defun hunchentoot::spad-eval (code)" _
"(let ((*package* (find-package :boot))" _
"(alg (boot::|parseAndEvalToString| code)))" _
"(format nil _"~{~A~%~}_" alg)))"
lisp1 "(hunchentoot:define-easy-handler " _
"(fricas-eval :uri _"/eval_") (code)" _
"(setf (hunchentoot:content-type*) _"text/plain_")" _
"(format nil _"~A~%_" (hunchentoot::spad-eval code)))"
start(port:PositiveInteger):SEX == htStart(port)$Lisp