Code Monkey home page Code Monkey logo

nawak's Introduction

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

nawak's People

Contributors

idlewan avatar

Watchers

Ray Leyva avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.