Skip to main content

An opinionated startup extension for FastAPI.

Project description

FastAPI Startup

An opinionated startup extension for FastAPI.

Usage

from fastapi_startup import FastAPIStartup

app = FastAPIStartup(
    site_name="My site",
    swagger_favicon_url="https://example.com/favicon.ico",
)

Opinions

This is an opinionated way to start FastAPI:

  • No ReDoc.
  • Swagger is hosted at the root_path.
  • Swagger UI oAuth2 redirect URL is /oauth2-redirect.
  • Endpoint /ping responds with the plain text response "pong".
  • Mounts static directory at /static (default).
  • Title and site name in Swagger
  • Assets (expects these files in the directory ./static/assets):
    • Favicon - favicon.ico.
    • Swagger CSS - swagger-ui.min.css.
    • Swagger Bundle JS - swagger-ui-bundle.min.js.

Config

Configure FastAPI as usual. Extra arguments (that can be accessed from app.extra):

Name Default Description
site_name Swagger UI Displayed in the Swagger title, with app.title.
static_dir static Where to mount the static directory. Disabled if value is falsy.
swagger_css_url /assets/swagger-ui.min.css URL to Swagger UI CSS file.
swagger_favicon_url /assets/favicon.ico URL to your Favicon.
swagger_js_url /assets/swagger-ui-bundle.min.js URL to Swagger JS bundle file.

If the swagger_ arguments starts with a "/" and static is mounted, they will be loaded from "static", else it will be treated as a URL.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi-startup-0.2.0.tar.gz (4.5 kB view hashes)

Uploaded Source

Built Distribution

fastapi_startup-0.2.0-py3-none-any.whl (3.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page