A super-charged FastAPI framework for even faster delivery
Project description
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.