Skip to main content

What’s Pyx?

Pyx is yet another async web server written in Python, with the asyncio module.

It’s small and simple. It has no dependency at all except Python itself.

Yet Pyx is also carefully crafted to behave nicely in stressful and dangerous enviroments.

How to install?

Just use pip or tools alike:

pip install pyxserver

What can Pyx do?

Pyx is a simple static file server by itself:

pyx -b localhost -p 8000 -r /some/where

This will start pyx and bind it to localhost:8000, serving files in the directory /some/where

And you can also use the small framework provided by Pyx to write your own dynamic web application:

import asyncio
from pyx import (HttpHeader, HttpConnectionCB)

@asyncio.coroutine
def req_cb(req):
    resp = req.respond(200)
    resp.headers.append(HttpHeader('Content-Length', 5))
    resp.headers.append(HttpHeader('Content-Type', 'text/plain'))
    yield from resp.send()
    yield from resp.send_body(b'hello')

loop = asyncio.get_event_loop()

conn_cb = HttpConnectionCB(req_cb)
starter = asyncio.start_server(conn_cb, '127.0.0.1', 8080, loop=loop)
_server = loop.run_until_complete(starter)

loop.run_forever()

Please see the implementation of pyx.http.StaticRootResource for a more sophisticated example.

License

Pyx is licensed under the terms of the MIT license.

Download files

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

Source Distribution

pyxserver-0.1.1.tar.gz (15.2 kB view details)

Uploaded Source

File details

Details for the file pyxserver-0.1.1.tar.gz.

File metadata

  • Download URL: pyxserver-0.1.1.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyxserver-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5e1c18edfb01d13bccc3914b51629d6b32cc8718781bce0d773ed5988923c6a4
MD5 49aa8fb67ea8a88e42456b79a6b0b437
BLAKE2b-256 68bceba8a7a5767e749e4af945b116038b8a12a41a505a1daf66fefe0d30154e

See more details on using hashes here.

Supported by

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