Skip to main content

A modern async python3 web framework

Project description

# Albatross

I wanted to see how simple it is to make an modern async web framework. (python3.5 only)

It turns out - it's dead simple.

```python
from albatross import Server
import asyncio

class Handler:
async def on_get(self, req, res):
await asyncio.sleep(0.1)
res.write('Hello, %s' % req.args['name'])


app = Server()
app.add_route('/(?P<name>[a-z]+)', Handler())
app.serve()
```

## Install

pip3 install albatross3

## Usage

Create an app. Create handlers that have async functions `on_get`, `on_post`, etc. Call add_route with regex-based routes
to add the handlers. Call `app.serve()`.

See `examples/` for examples.

## Features

- You can read the entire codebase in about 10 minutes.
There are probably many non-HTTP-compliant and subtle bugs as a consequence, but
it works for building simple or moderately complex servers right now!

- It's natively async

- This works with the awesome `uvloop` project. It doesn't yet work with pypy3, because they don't support python3.5.
Let's make it happen!

## Framework

The entire framework is 4 files at the moment:

- status_codes.py - blatantly copied from Falcon, because they did such a great job with that framework.
- server.py - the web server you instantiate, add routes & handlers, and allows you to serve
- request.py - a web request object
- response.py - a web response object

Each of those is less than 100 lines or so.

## Current Gotchas

- Be careful with casing on HTTP headers. The framework should force standardization, but currently they are case-sensitive.

## Todo

- tests: tests are a good idea. I should write some.

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

albatross3-0.1.2.tar.gz (6.5 kB view hashes)

Uploaded Source

Built Distribution

albatross3-0.1.2-py3-none-any.whl (9.3 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