Skip to content
/ nawak Public

A web micro-framework in Nimrod, heavily inspired by jester, flask and the like.

License

Notifications You must be signed in to change notification settings

idlewan/nawak

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nawak

A web micro-framework in Nimrod, heavily inspired by jester, flask and the like. It is only compatible with the Mongrel2 server for now.

Minimal example

# helloworld.nim
import nawak_mongrel, strutils

get "/":
    return response("Hello World!")

get "/user/@username/":
    return response("Hello $1!" % url_params.username)

run()

Installation

Install Mongrel2 v1.8.1 (download page <http://mongrel2.org/downloads/>_) by following the instructions in the manual. The bindings for ZeroMQ may only work with ZeroMQ version 4.

Start Mongrel2 either with the provided Makefile in the example/conf/ folder, or manually:

$ cd example/conf
$ mkdir -p run logs tmp
$ m2sh load
$ sudo m2sh start -every

Please check that you use a recent compiler version of Nimrod/Nim. nawak only works with a fresh Nimrod compiler.

You can now compile and execute the examples from the example folder:

$ cd example
$ nimrod c -d:release helloworld.nim
$ ./helloworld
$ firefox http://localhost:6767/

The nawak_app.nim example answers the requirements of the web framework benchmarks. You will want to install PostgreSQL and create the database and tables to test it out.

Performance test

If you want to make changes and see how it performs, you can use wrk to have a preview of the performance. The command-line options you will want to use are (from the web framework benchmarks):

$ wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' -H 'Connection: keep-alive' -d 15 -c 256 -t 1 http://localhost:6767/json

About

A web micro-framework in Nimrod, heavily inspired by jester, flask and the like.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published