117 lines
3.3 KiB
Common Lisp
117 lines
3.3 KiB
Common Lisp
(defparameter *server* (make-instance 'tbnl:easy-acceptor
|
|
:port 33333
|
|
:address "0.0.0.0"))
|
|
(defun start ()
|
|
(tbnl:start *server*))
|
|
|
|
(defun stop()
|
|
(tbnl:stop *server*))
|
|
|
|
(defparameter *css*
|
|
"body {
|
|
background: #f0f2f5;
|
|
font-family: monospace;
|
|
}
|
|
.nav-wrapper {
|
|
background-color: blue;
|
|
padding: 15px;
|
|
}
|
|
.form-wrapper {
|
|
position: relative;
|
|
top: 55px;
|
|
padding: 15px 10px;
|
|
background-color: #fff;
|
|
width: 400px;
|
|
border-radius: 5px;
|
|
box-shadow: 8px 8px 8px lightgrey;
|
|
}
|
|
.username {
|
|
position: relative;
|
|
display: flex;
|
|
margin-left: auto;
|
|
margin-right: auto;
|
|
border: 1px solid lightgrey;
|
|
border-radius: 5px;
|
|
padding: 15px;
|
|
font-size: 1.2rem;
|
|
width: 95%;
|
|
}
|
|
.password {
|
|
position: relative;
|
|
display: flex;
|
|
margin-left: auto;
|
|
margin-right: auto;
|
|
border: 1px solid lightgrey;
|
|
border-radius: 5px;
|
|
padding: 15px;
|
|
font-size: 1.2rem;
|
|
width: 95%;
|
|
}
|
|
.nav-wrapper a {
|
|
margin-left: 15px;
|
|
margin-right: 15px;
|
|
text-decoration: none;
|
|
font-size: 1rem;
|
|
color: #fff;
|
|
}
|
|
.nav-wrapper a:hover {
|
|
cursor: pointer;
|
|
text-decoration: underline;
|
|
}
|
|
.title-wrapper {
|
|
display: flex;
|
|
justify-content: center;
|
|
}
|
|
.content {
|
|
font-size: 1.1rem;
|
|
}")
|
|
|
|
(tbnl:define-easy-handler (main :uri "/")
|
|
()
|
|
(spinneret:with-html-string
|
|
(:html
|
|
(:head
|
|
(:style
|
|
*css*))
|
|
(:body
|
|
(:div :class "whole-wrapper"
|
|
(:div :class "nav-wrapper"
|
|
(:a :class "home-link" :href "/"
|
|
"Home")
|
|
(:a :class "about-link" :href "/about"
|
|
"About"))
|
|
(:div :class "title-wrapper"
|
|
(:h1 :class "title"
|
|
"Welcome to my CL server!"))
|
|
(:div :class "form-wrapper"
|
|
(:form :class "login" :action "/members" :method "POST"
|
|
(:input :type "text" :class "username" :name "username" :placeholder "Username")
|
|
(:br)(:br)
|
|
(:input :type "password" :class "password" :name "password" :placeholder "Password"))))))))
|
|
|
|
(tbnl:define-easy-handler (about :uri "/about")
|
|
()
|
|
(spinneret:with-html-string
|
|
(:html
|
|
(:head
|
|
(:style
|
|
*css*))
|
|
(:body
|
|
(:div :class "whole-wrapper"
|
|
(:div :class "nav-wrapper"
|
|
(:a :class "home-link" :href "/"
|
|
"Home")
|
|
(:a :class "about-link" :href "/about"
|
|
"About"))
|
|
(:div :class "content-wrapper"
|
|
(:div :clsas "about-title-wrapper"
|
|
(:h1 "About this site"))
|
|
(:div :class "content-wrapper"
|
|
(:p :class "content"
|
|
"I am an intermediate programmer who is new-ish to common assoc.lisp
|
|
and am loving it so far! So much so that I have decided to practice
|
|
making a webserver; though i usually do this with node js, handling
|
|
request with response, i decided to do the same with common lisp!
|
|
I will be using hunchentoot, spinneret and lass(maybe?) to create
|
|
this site; I hope you enjoy :)"))))))))
|