Skip to main content

A way to create a lightning fast HTTP server using ASGI

Project description

Brisk

The fast ASGI framework


Repository

Table of Contents

  1. Usage
  2. Documentation

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


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)

Uploaded Source

Built Distribution

Brisk_py-0.2.0-py3-none-any.whl (7.2 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