Skip to main content

web server

Project description

npynx

twisted based http server with multiple domain support

usage

from test/TestServer.py

from jinja2 import Template
from npynx import Server, Domain, response


class DomainTest(Domain):
    root_template = Template("ON {{ ROOT }}")

    def root(self, *args):
        return response(body=self.root_template.render(content="/"))

    def another(self, *args):
        return response(body=self.root_template.render(content="/another"))

    def __init__(self):
        Domain.__init__(self, "127.0.0.1:4200", {
            "": self.root,
            "/": self.root,
            "/another": self.another,
        })


if __name__ == '__main__':
    server = Server("tcp:4200")
    domain_test = DomainTest()
    server.add_domain(domain_test)

    try:
        server.start()
        server.join()
    except KeyboardInterrupt:
        server.terminate()

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

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

Source Distribution

npynx-1.0.tar.gz (2.9 kB view hashes)

Uploaded Source

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