Skip to content

madelyneriksen/phial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Phial - A Simple ASGI Framework

Phial is an async micro-framework for the web written in Python. Created as an educational project, I wanted a better understanding of how async programming works in Python. Additionally, I wanted a chance to work closer to the actual HTTP protocol and understand more about the web.

I took heavy inspiration from the Bottle framework, in both philosophy and code. Disregarding tests, the source code for Phial fits in one file and can easily be read in an afternoon.

Using Phial

Note: Phial isn't for use in production! I created Phial to understand more about the HTTP protocol. If you need an async microframework, try Starlette

Creating a "Hello, world!" in Phial is simple, it should look familiar if you have ever used Flask, Bottle, or another micro-framework:

# hello.py
from phial import Router, Phial, Response

ROUTER = Router()

@ROUTER.route(r'^/$')
async def hello(request):
    return Response("Hello World", content_type="text/plain")

app = Phial(router=ROUTER)

Run this file hello.py using an ASGI server like Uvicorn:

uvicorn hello:app

Running Tests

After cloning the repo, install the development packages from requirements.dev.txt:

pip install -r requirements.dev.txt

Tests are run with the pytest command and framework.

License

  • MIT License

Releases

No releases published

Packages

No packages published

Languages