ConfigurationΒΆ

nanohttp have a great human-friendly configuration system with help of YAML and pymlconf.

Create a demo.yml file. The file below is same as the default configuration.

debug: true

domain:

cookie:
  http_only: false
  secure: false

You may use nanohttp.settings anywhere to access the config values.

from nanohttp import Controller, html, settings

class Root(Controller):

    @html
    def index(self):
        yield '<html><head><title>nanohttp demo</title></head><body>'
        yield '<h2>debug flag is: %s</h2>' % settings.debug
        yield '</body></html>'

Passing the config file(s) using command line:

$ nanohttp -c demo.yml [-c another.yml] demo

Passing the config file(s) Using python:

from nanohttp import quickstart

quickstart(Root(), config='<YAML config string>')