Utilities for albatross web framework
Project description
Handler
There are handlers for:
static files
static directories
server health & profiling
jinja2 templating
Middleware
There is middleware for:
authentication
logging
statsd
cors cross-browser authorization
Example
from albatross import Server
from albatross_extras.handler import HealthHandler
from albatross_extras.middleware import (
StatsdMiddleware,
LoggingMiddleware,
)
from albatross_extras.lib import logging
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()
logger = logging.get_logger('my-app.web')
app.add_middleware(LoggingMiddleware(logger)
app.add_middleware(StatsdMiddleware())
app.add_route('/health', HealthHandler())
app.serve()
# You'll now emit stats to statsd and log in JSON format to stdout
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
albatross_extras-0.1.3.tar.gz
(7.6 kB
view hashes)
Built Distribution
Close
Hashes for albatross_extras-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 773a86333cef5e938bcc80659b5ac2d95c345f33560d1156b6c59d285750fe07 |
|
MD5 | 201aab2fb7f8bae4147df0ef75bf9219 |
|
BLAKE2b-256 | a94733a386ea27cd8cdbc2e07508caf116a9e4b221e13d4dd235abbe4af88914 |