Skip to main content

This is a simple http server, use MVC like design.

Project description

Naja Atra WSGI

This ia a WSGI proxy that proxies requests to Naja Atra.

Usage

from naja_atra import route
from naja_atra_wsgi import app
from wsgiref.simple_server import make_server

@route("/hello")
def hello(name: str):
    return {"messag": f"Hello, {name}!"}

if __name__ == '__main__':
    server = make_server('0.0.0.0', 8080, app)
    server.serve_forever()

You can use server.scan() to import routes from other modules. And also you can use naja_atra_wsgi.config() to function to sepecify the static resources routes.

import os
import naja_atra.server as server

from wsgiref.simple_server import make_server
from naja_atra_wsgi import config, app

PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))

if __name__ == '__main__':
    
    server.scan(base_dir="tests/ctrls", regx=r'.*controllers.*')
    config(resources={"/public/*": f"{PROJECT_ROOT}/tests/static",
                    "/*": f"{PROJECT_ROOT}/tests/static"})

    wsgi_server = make_server("", 9090, app)
    wsgi_server.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

naja-atra-wsgi-1.0.2.tar.gz (6.8 kB view hashes)

Uploaded Source

Built Distribution

naja_atra_wsgi-1.0.2-py3-none-any.whl (7.0 kB view hashes)

Uploaded Python 3

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