Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/abdur-rahmaanj/fastoo
Super-charged frameworks for building big fastapi apps
https://github.com/abdur-rahmaanj/fastoo
fastapi
Last synced: 9 days 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 (about 1 year ago)
- Default Branch: stable
- Last Pushed: 2023-08-26T10:10:38.000Z (about 1 year ago)
- Last Synced: 2024-10-30T19:06:15.931Z (9 days ago)
- Topics: fastapi
- Language: Python
- Homepage:
- Size: 23.4 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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 Dependsfrom 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