• Stars
    star
    109
  • Rank 319,077 (Top 7 %)
  • Language
    Nim
  • License
    MIT License
  • Created almost 11 years ago
  • Updated about 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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