https://github.com/abdur-rahmaanj/fastoo
Super-charged frameworks for building big fastapi apps
https://github.com/abdur-rahmaanj/fastoo
fastapi
Last synced: about 1 year ago
JSON representation
Super-charged frameworks for building big fastapi apps
- Host: GitHub
- URL: https://github.com/abdur-rahmaanj/fastoo
- Owner: Abdur-rahmaanJ
- License: mit
- Created: 2023-08-22T16:02:09.000Z (almost 3 years ago)
- Default Branch: stable
- Last Pushed: 2025-04-08T20:15:57.000Z (about 1 year ago)
- Last Synced: 2025-04-08T21:25:10.211Z (about 1 year ago)
- Topics: fastapi
- Language: Python
- Homepage:
- Size: 24.4 KB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fastoo
[](https://pepy.tech/projects/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
```python
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
```python
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
```py
module = Module(__file__, render_own_templates=True, templates="custom/path")
```
If you don't want the whole goodies, just call
```py
from fastoo import render_template
...
return render_template("template/path", {}, request, directory="custom/templates/path")
```
## Modules
Modules must contain info.toml like this
```toml
[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