Skip to content

ZeroIntensity/view.py

Repository files navigation

view.py logo

The Batteries-Detachable Web Framework

Tests Valgrind Build

Warning

view.py is currently in alpha, and may be lacking some features. If you would like to follow development progress, be sure to join the discord.

Features

  • Batteries Detachable: Don't like our approach to something? No problem! We aim to provide native support for all your favorite libraries, as well as provide APIs to let you reinvent the wheel as you wish.
  • Lightning Fast: Powered by pyawaitable, view.py is the first web framework to implement ASGI in pure C, without the use of external transpilers.
  • Developer Oriented: view.py is developed with ease of use in mind, providing a rich documentation, docstrings, and type hints.

See why I wrote it on the docs.

Examples

from view import new_app

app = new_app()

@app.get("/")
async def index():
    return await app.template("index.html", engine="jinja")

app.run()
# routes/index.py
from view import get, HTML

# Build TypeScript Frontend
@get(steps=["typescript"], cache_rate=1000)
async def index():
    return await HTML.from_file("dist/index.html")
from view import JSON, body, post

@post("/create")
@body("name", str)
@body("books", dict[str, str])
def create(name: str, books: dict[str, str]):
    # ...
    return JSON({"message": "Successfully created user!"}), 201

There's C code in here, how do I know it's safe?

view.py is put through rigorous testing, checked with Valgrind, and checks for memory leaks, thanks to Memray. See the testing badges at the top.

Installation

Python 3.8+ is required.

Development

$ pip install git+https://github.com/ZeroIntensity/view.py

PyPI

$ pip install view.py

Pipx

$ pipx install view.py

Copyright

view.py is distributed under the terms of the MIT license.

view.py is affiliated with Space Hosting