III Common FastAPI base.
Project description
III API base
Usage
Config
The later config will override the previous one.
This table shows the predefined environment variables.
Keyword | Type | Default | Description |
---|---|---|---|
DEBUG |
boolean | false | To set the logging as DEBUG state. |
RELOAD |
boolean | false | To auto reload the FastAPI application. |
APP_NAME |
string | Backend API | The application name shows on Swagger. |
from pathlib import Path
from api_helper.config import load_config
# Load config
load_config(Path(__file__).parent / ".env")
# Load default config in the directory (.env)
load_config(Path(__file__).parent)
FastAPI example
To config the FastAPI by env, read the Config section.
from pathlib import Path
from api_helper import FastAPI, success_response
app: FastAPI = FastAPI(base_folder=Path(__file__).parent)
# Optional to setup sentry
app.setup_sentry("sentry_dsn")
@app.get("/")
def home():
return success_response("Hello, World!")
# Start the app and enjoy
app.run("127.0.0.1", 5000)
Build backend
hatch
hatch env create
hatch build
hatch publish -r test
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
iii_api_helper-0.0.7.tar.gz
(16.5 kB
view hashes)
Built Distribution
Close
Hashes for iii_api_helper-0.0.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ddb00c8421bfb99bae28647710be24a6a828cadebb360f5256628ef12dd406ee |
|
MD5 | 5ab69a423f5dca18a340e2cb3db8ed4a |
|
BLAKE2b-256 | 57ef5b004da3b3f589a07927d9cbb94f5647a70e6e1a0e6bee082ad61077e859 |