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, redoc_url, favicon_url, and static_url are passed through to FastAPI(). docs_url and redoc_url are handled by fastapi-offline, and use the same syntax as normal fastapi library.
static_url can be used to set the path for the static js/css files, e.g. static_url=/static-files (default: /static-offline-docs).
Using a custom shortcut icon
By default, the FastAPI favicon.png is included and used as the shortcut icon on the docs pages. If you want to use a different one, you can specify it with the favicon_url argument:
app = FastAPIOffline(
favicon_url="http://my.cool.site/favicon.png"
)
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.
- The FastAPI
favicon.pngfile is included in this package. The original license (MIT) and copyright apply to that file.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastapi_offline-1.7.6.tar.gz.
File metadata
- Download URL: fastapi_offline-1.7.6.tar.gz
- Upload date:
- Size: 745.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c84d08584faa646932951b493106992caa79b838e454f14dd410cef9a1a5e07d
|
|
| MD5 |
df42b546a8a2babe1e31ea0b04292950
|
|
| BLAKE2b-256 |
008e6f1d86982f09ecf9d326c7313d2e6be0a96d979130a87f61022c807a7414
|
File details
Details for the file fastapi_offline-1.7.6-py3-none-any.whl.
File metadata
- Download URL: fastapi_offline-1.7.6-py3-none-any.whl
- Upload date:
- Size: 744.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24d6851b5a94c50f669594b7ab9d1bbe3a4c0a53c4f4e9ce47798ff4591790d2
|
|
| MD5 |
3eafb2847874790a4f74b075f601eb42
|
|
| BLAKE2b-256 |
ad5610bd6900c99d9ecb3d803583b3736e8d741f19f04dd39e36aa7ad776c638
|