Skip to main content

High performance web framework built with uvloop and httptools.

Project description


Build License Pypi Python

High performance web framework built with uvloop and httptools

In Xweb, everything is asynchronous.


  • High performance.
  • Asynchronous.
  • Small.


  • Python3.6+


pip install xweb

Get Started

Hello World

from xweb import App

app = App()

async def response(ctx):
    ctx.res.body = "Hello World"

if __name__ == '__main__':

Example with middleware.

A middleware is an async function or an async callable object which looks like: async def logger(ctx, fn)


import time

from xweb import App

app = App()

async def logger(ctx, fn):
    await fn()
    rt = ctx['X-Response-Time']

async def response_time(ctx, fn):
    start = time.time()
    await fn()
    usage = (time.time() - start) * 1000_000
    ctx['X-Response-Time'] = f'{usage:.0f}µs'

async def response(ctx):
    ctx.res.body = "Hello World"

if __name__ == '__main__':



  • app.use(fn)
  • app.listen(host='', port=8000, debug=True)


  • ctx.req
  • ctx.res
  • ctx.send
  • ctx.abort(self, status, msg="", properties="")
  • ctx.check(self, value, status=400, msg='', properties="")


ctx.req is a Request object.

  • ctx.req.headers dict
  • ctx.req.method str
  • ctx.req.url str
  • ctx.req.raw bytes
  • ctx.req.ip str


ctx.res is a Request object.

  • ctx.res.body str
  • ctx.res.status int
  • ctx.res.msg str
  • ctx.res.headers dict


  • Benchmark code in benchmarks/.
  • environment: iMac (Retina 4K, 21.5-inch, 2017), 3 GHz Intel Core i5, 8 GB 2400 MHz DDR4
  • test command: wrk -c 100 -t 10 -d 10 -T 10
Frameworks Requests/Sec Version
xweb 100000 0.1.1
vibora 90000 0.0.6
meinheld + wsgi 77000 0.6.1
sanic 50000 0.7.0

Deploy and Run



  1. pip install -r requirement.txt
  2. pytest --cov


Build Middleware.

XWeb is inspired by koajs. I need some help for writing middleware as in koa. For example:

  1. Body parser. Convert the raw bytes body into dict or file.
  2. Data validator. Async data validator with high performance.
  3. Router. High performance router like koa-router.
  4. etc..

Open issue.

  1. Suggestion.
  2. Bug.

Download files

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

Files for xweb, version 3.0.1
Filename, size File type Python version Upload date Hashes
Filename, size xweb-3.0.1-py3-none-any.whl (5.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size xweb-3.0.1.tar.gz (4.8 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page