fastoo
A powerful framework for dealing with FastAPI apps.
It includes various utilities for building big FastAPI apps, inclding templates and modules.
Quickstart
-m means add default modules
python -m pip install fastoo==0.1.4
fastoo new blog -m
cd blog
uvicorn app:app --reload
More commands
fastoo module bing
Creates a new module named bing in modules/
Url defined in info.toml.
Can be changed to what we want. Default is /module_name
Configs
Define configuration profile in init (development, production, testing)
In your apps import get_settings from init
Render templates
consider this
.
├── api
│ ├── __init__.py
│ ├── module.py
│ └── templates.py
├── app.py
├── cli.py
├── config.py
├── __init__.py
├── init.py
├── modules
│ └── auth
│ ├── business.py
│ ├── models.py
│ ├── templates
│ │ └── abc.html
│ └── view.py
└── templates
└── themes
├── back
└── front
└── dingy
└── index.html
imports
from fastoo.api.module import Module
from fastapi import APIRouter
from fastapi import Request
from fastapi import Depends
from typing import Annotated
from pydantic_settings import BaseSettings
from init import get_settings
If we set render_own_templates to True, render_template will look in a folder called templates in the mdoules folder
router = APIRouter(include_in_schema=False)
module = Module(__file__, render_own_templates=True)
@router.get("/login/")
def login(request: Request):
with module.set(request) as m:
return module.render_template("abc.html", {})
This can be overriden using
module = Module(__file__, render_own_templates=True, templates="custom/path")
If you don't want the whole goodies, just call
from fastoo import render_template
...
return render_template("template/path", {}, request, directory="custom/templates/path")
Modules
Modules must contain info.toml like this
[base]
url_prefix = "/auth"
A module includes
- view.py
- forms.py # stafrlette-wtforms
- models.py
- info.toml
- business.py # view logic goes here
Validation
fastoo.api.validation has these helpful features
- verify_slug # for wtf forms
- is_valid_url
- is_valid_slug
- is_empty_str
- is_alpha_num_underscore
Release files for Fastoo 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| Fastoo-0.1.4.tar.gz | 8.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| Fastoo-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.0 kB
Release files / Fastoo-0.1.4.tar.gz
| Download URL | Fastoo-0.1.4.tar.gz |
|---|---|
| Size | 8.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ca842b18012f4050090183e9f9dd7631e9dcb2e0f3ef882f8118a1e69d90317c
|
|
BLAKE2b-256 checksum How to use checksums |
a89c49dd888262dc50152d5fd7152580723a2c3624ab4c70790bacacc263eec2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Release files / Fastoo-0.1.4-py3-none-any.whl
| Download URL | Fastoo-0.1.4-py3-none-any.whl |
|---|---|
| Size | 11.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2a52deb934813ce7f23e51cef3ea8b03872c9d9adc8b04d773a3e532097e5aec
|
|
BLAKE2b-256 checksum How to use checksums |
4059eae26aa0638a6ae2ad33f169e2944538bba68763092f70f2438e7087b315
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|