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.png
file 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
File details
Details for the file fastapi_offline-1.7.3.tar.gz
.
File metadata
- Download URL: fastapi_offline-1.7.3.tar.gz
- Upload date:
- Size: 741.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f918208c9054b878482cd5e7c4d8dc0e59e7e02523d3dba025bb32979af77101 |
|
MD5 | 16233384f7cc1a82063197d0b3896830 |
|
BLAKE2b-256 | 9074c58dcb3c5767fa04cdef43c2f3dfee44678dddac3edbd39bed157a977160 |
File details
Details for the file fastapi_offline-1.7.3-py3-none-any.whl
.
File metadata
- Download URL: fastapi_offline-1.7.3-py3-none-any.whl
- Upload date:
- Size: 741.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 224c2a81b9f074bf1000eb89ac6d2b3175b9c8c18fd4ef5ee4f96fc9d3c9c691 |
|
MD5 | 5e579f11ea5d0c959bc90fd9b98a430d |
|
BLAKE2b-256 | 03bd96f6832a3cd8e2eb7a11d13caac8293f10fb2494ba674bbb544b90b0d572 |