A way to create a lightning fast HTTP server using ASGI
Project description
Brisk
The fast ASGI framework
Table of Contents
Usage
Install using pip:
pip install brisk-py
Basic Example:
from brisk_py import brisk
app = brisk.App()
# simple routing
@app.get('/')
def route(request):
return '<h1>Hello World</h1>'
# render html file
@app.get('/')
def route(request):
return brisk.html('index.html')
Create an api
from brisk_py import brisk
app = brisk.App()
users = {'users': [{'user': 'John Doe', 'age': 34}, {'user': 'Jane Doe', 'age': 37}]}
@app.get('/users')
def route(request):
return users
@app.get('/user')
def route(request):
user = request.body.get('user')
if user:
return users.get(user, {'message': 'user not found'})
else:
return {'message': 'no user provided'}
@app.post('/users')
def route(request):
user = request.body.get('user')
age = request.body.get('age')
if age and user:
users.append({'user': user, 'age': age})
return {'message': 'success'}
else:
return {'message': 'error'}
Run Python in HTML
# main.py
from brisk_py import brisk
app = brisk.App()
@app.get('/')
def route(request):
fav_things = ['raindrops on roses', 'whiskers on kittens', 'bright copper kettles', 'warm woolen mittens']
return html('index.html', fav_things=fav_things)
Documentation
TBD
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Brisk-py-0.2.0.tar.gz
(6.6 kB
view hashes)