Skip to main content

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()

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 details)

Uploaded Source

File details

Details for the file npynx-1.0.tar.gz.

File metadata

  • Download URL: npynx-1.0.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for npynx-1.0.tar.gz
Algorithm Hash digest
SHA256 96e12b44940b140655b1aeac094273cfca9c2342114cf1141c6df5c1d71a0157
MD5 793d15e2771789194d80fb985eff730c
BLAKE2b-256 79677cbd4a1453e85328d5551f522a363e94693062799f8369b96e07ee2af7c4

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0 This release

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page