FastAPI without reliance on CDNs for docs
Project description
Overview
FastAPI is awesome, but the documentation pages (Swagger or Redoc) all depend on external CDNs, which is problematic if you want to run on disconnected networks.
This package includes the required files from the CDN and serves them locally. It also provides a super-simple way to get a FastAPI instance configured to use those files.
Under the hood, this simply automates the process described in the official documentation here.
Installation
You can install this package from PyPi:
pip install fastapi-offline
Example
Given the example from the FastAPI tutorial:
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello World"}
Simply create a fastapi_offline.FastAPIOffline
object instead:
from fastapi_offline import FastAPIOffline
app = FastAPIOffline()
@app.get("/")
async def root():
return {"message": "Hello World"}
Any options passed to FastAPIOffline()
except docs_url
and redoc_url
are passed through to FastAPI()
.
Disabling Docs Page
If you wish to disable the docs page, for
example in a sub-application, revert to using the default FastAPI()
class.
app = FastAPI(openapi_url=None)
Licensing
- This code is released under the MIT license.
- Parts of Swagger are included in this package. The original license (Apache 2.0) and copyright apply to those files.
- Parts of Redoc are included in this package. The original license (MIT) and copyright apply to those files.
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
Built Distribution
Hashes for fastapi_offline-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9825ce1b567352e47c6be9b70e01063a80fcb82d8d329a774dbe7b63a50e0f8c |
|
MD5 | 7882089c58bf8be6dde0aba9743e4a11 |
|
BLAKE2b-256 | 731395af3bf9186679c394947c0c10b6d51aad067f83b64b7db9e84daf3b56a0 |