All Projects → defunkydrummer → ninglex

defunkydrummer / ninglex

Licence: MIT license
Easy to learn, quick and dirty, bare-bones web framework for Common Lisp

Programming Languages

common lisp
692 projects
CSS
56736 projects

Projects that are alternatives of or similar to ninglex

Thruster
A fast, middleware based, web framework written in Rust
Stars: ✭ 671 (+2064.52%)
Mutual labels:  web-development, web-framework
framework
Cygnite PHP Framework- A Modern Toolkit For Web Developers
Stars: ✭ 43 (+38.71%)
Mutual labels:  web-development, web-framework
Denovel
A Deno Framework For Web Artisan - Inspired by Laravel
Stars: ✭ 128 (+312.9%)
Mutual labels:  web-development, web-framework
nardis
A small web framework based on ASGI
Stars: ✭ 14 (-54.84%)
Mutual labels:  web-development, web-framework
Javalite
JavaLite is a cohesive collection of frameworks designed from ground up to add pleasure back to your daily life
Stars: ✭ 753 (+2329.03%)
Mutual labels:  web-development, web-framework
Toruk
Go web 开发脚手架
Stars: ✭ 78 (+151.61%)
Mutual labels:  web-development, web-framework
Rocket
A web framework for Rust.
Stars: ✭ 15,760 (+50738.71%)
Mutual labels:  web-development, web-framework
JayantGoel001
JayantGoel001's profile with 74 stars ⭐ and 91 forks 🎉.
Stars: ✭ 74 (+138.71%)
Mutual labels:  web-development
rango
Random. Django. Rango. An introduction to using Python and Django to build a website.
Stars: ✭ 53 (+70.97%)
Mutual labels:  web-development
Coding-Ninjas-Full-Stack-Web-Development
It contains all the files I created during the MERN full stack web development course with coding ninjas
Stars: ✭ 108 (+248.39%)
Mutual labels:  web-development
kapsule
Kapsule - A closure based Web Component library
Stars: ✭ 43 (+38.71%)
Mutual labels:  web-framework
resources
A curated collection of useful tech resources 💻
Stars: ✭ 57 (+83.87%)
Mutual labels:  web-development
colt-steele-advanced
Notes for the Colt Steele Advanced Boot Camp
Stars: ✭ 29 (-6.45%)
Mutual labels:  web-development
zap
⚡ fast http framework for rust
Stars: ✭ 51 (+64.52%)
Mutual labels:  web-framework
best-of-react
🏆 A ranked list of awesome React open-source libraries and tools. Updated weekly.
Stars: ✭ 364 (+1074.19%)
Mutual labels:  web-development
tanuki
Tanuki is a polyglot web framework that allows you to develop web applications and services in multiple programming languages.
Stars: ✭ 62 (+100%)
Mutual labels:  web-framework
esri-leaflet-vector
Display ArcGIS Online vector basemaps w/ Esri Leaflet
Stars: ✭ 39 (+25.81%)
Mutual labels:  web-development
node-ray
Debug your NodeJS & web code with Ray to fix problems faster
Stars: ✭ 39 (+25.81%)
Mutual labels:  web-development
deck.gl-time-series-widget
A React Time Slider implementation for DECK.GL - (non)temporal data - by CPU filtering ⌛
Stars: ✭ 19 (-38.71%)
Mutual labels:  web-development
amber-introduction
Introduction to the Amber web framework and its features
Stars: ✭ 53 (+70.97%)
Mutual labels:  web-framework

Ninglex

A really tiny, ready-to-go micro web framework for simple, quick and dirty stuff, based on Ningle. It is ready to go, learning curve almost zero.

What is it good for?

  • When you are coding a bit of Lisp and you need to output some HTML locally on your browser, or JSON, or etc, in the minimal amount of time

  • When you are a beginner and want your Lisp to serve HTML pages or you want to write a minimal Lisp backend.

Why?

Not as small as Ningle and not as big as Caveman2.
Ningle was too minimal, so Ninglex adds just a few functions and macros on top of Ningle, then gets you ready to go!

Ninglex is only about defining your routes and your route handlers. Starting and stopping the server. The rest is left to your control.

Underlying Ninglex is Eitaro Fukamachi's Clack & Lack, which allows different servers, so your app can be hosted using Hunchentoot Wookie, etc. What this means is that there's something that you want to do with Ninglex and you don't know how to do, you can do it by glancing at Clack and Lack's documentation.

Usage

See example directory and load system "ninglex-example". Don't have time for that? This is most of example.lisp, assuming you have loaded libraries "jonathan" and "spinneret", otherwise example 2 and 3 below will not work:

For newbies: Make sure you load the package. For this example we'll be inside the package "Ninglex". If we are on other package we'll have to prefix all function calls with "ninglex:"

;; load lib
(ql:quickload :ninglex)
(in-package :ninglex)

Example 1: Define your own route handler function, which will take two params: "age" and "name".

This will make your server answer GET requests on http://localhost:5000

The supplied parameters "name" and "age" will be available as "n" and "a" values.

(defun my-fun (params)
  (with-request-params params ((n "name") (a "age"))
    (string-response
     (format nil "Hello, ~a of ~a years old!" n a))))

;; and then, I bind this function to a route 
(set-route "/hello" #'my-fun)

Now we need to start the server

(start ) 

Try: http://localhost:5000/hello?name=XYZ&age=99

(stop) stops the server.

We can do the same, but in less lines, without having to do a "defun".

(with-route ("/hello2" my-params)
  (with-request-params my-params ((n "name") (a "age"))
      (string-response
       (format nil "Hello, ~a of ~a years old!" n a))))

Want to capture parametrized URLs? This example is useful: (here we are using spinneret to output html)

(with-route ("/person/:name" params)
  (with-request-params params ((n :name))
    (ninglex:html-response
     (with-output-to-string (*html*)
       (with-html
         (:p :class "title is-1" n)

;; etc

Want to output JSON? make sure you load the Jonathan library (Newbies: do (ql:quickload "jonathan"))

;; FYI: "jojo" is synonymous for the Jonathan package
(with-route ("/jsontest" params) 
  (declare (ignore params))
  (json-response ;like string-response but sets correct http content-type
   (jojo:to-json '(:|name| "Common Lisp" :born 1984 :impls (SBCL CLISP)))))

Try: http://localhost:5000/jsontest

Want to output HTML? Ok, let's use the "spinneret" library by Ruricolist (of course you can use other HTML library):

(with-route ("/html-hello" params)
  (declare (ignore params))
  (html-response  ;this just sets the content-type accordingly
   (with-output-to-string (*html*)
     (with-html
       (:doctype)
       (:html
        (:head
         (:title "title"))
        (:body (:h1 "Hello Common Lisp!")
               (:img :src "static/logo-compact.png")))))))

The above example uses a static file dir thus needs the following:

;; Set static root directory for serving the static files
(defparameter *static-root*
  (merge-pathnames #P"static/"
                   (uiop:pathname-directory-pathname
                    (or *load-pathname*
                        *compile-file-pathname*))))

(defun start-example ()
  "Start the server"
  (start :static-root *static-root*))

We can (stop ) the server and start again:

(start-example )

The above example showed 90% of what you need about Ninglex. Want to define a handler for POST requests? use :POST instead of :GET on set-route or with-route

More info available by taking a look at Ningle.

Acknowledgements

Ninglex is Ningle eXtended, that is, it is based on Eitaro Fukamachi's ningle. As well as based of course in Eitaro's Clack and Lack. Thanks Eitaro!

License

Licensed under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].