Skip to main content

Yet another WSGI web framework

Project description

https://travis-ci.org/renskiy/marnadi.svg?branch=master

Yet another WSGI Web Framework, the simplest and fastest ever written.

Has no dependencies. Works both with Python 2 and Python 3.

Features

  • Support both of functional and object-oriented programming styles

  • Dynamic routes, e.g. “/path/{param}/”

  • Headers, query, data, cookies descriptors

  • Rich extending abilities

Installation

Simply execute following line:

pip install marnadi

“Hello World”

Run this script and open http://localhost:8000/ on your browser:

from marnadi import Response
from marnadi.wsgi import App

application = App()


@application.route('/')
@Response.get
def main_page():
    return 'This is main page'

if __name__ == '__main__':
    from wsgiref.simple_server import make_server
    make_server('', 8000, application).serve_forever()

More complex example

Script below additionally will respond to http://localhost:8000/foo/bar/ and http://localhost:8000/foo/ requests:

from marnadi import Response, Route
from marnadi.wsgi import App


class MainPageResponse(Response):

    def get(self):
        return 'This is main page'


class FooBarResponse(Response):

    def get(self, foo, bar=None):
        return 'foo is {foo}, bar is {bar}'.format(foo=foo, bar=bar)

routes=(
    Route('/', MainPageResponse),
    Route('/{foo}/', FooBarResponse, routes=(
        Route('{bar}/', FooBarResponse),
    )),
)

application = App(routes=routes)

if __name__ == '__main__':
    from wsgiref.simple_server import make_server
    make_server('', 8000, application).serve_forever()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Marnadi-0.5.3.tar.gz (11.1 kB view details)

Uploaded Source

File details

Details for the file Marnadi-0.5.3.tar.gz.

File metadata

  • Download URL: Marnadi-0.5.3.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Marnadi-0.5.3.tar.gz
Algorithm Hash digest
SHA256 bbe7bebbcf77adab0b4cd32253dca10233811dbb8e37fdcc89b54f87f942e0bd
MD5 f227e7932967af52995e1439ed5ae928
BLAKE2b-256 0a1777da59846e875b661424a9634010623653f67e690c196429cbb30cdd3d90

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page