Skip to main content

Overview

Test codecov

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.

Metadata

Release files for wigm-fastapi-offline 1.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wigm-fastapi-offline 1.6.0
File Size Uploaded
wigm_fastapi_offline-1.6.0.tar.gz 750.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wigm-fastapi-offline 1.6.0
File Interpreter ABI Platform
wigm_fastapi_offline-1.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 1.5 MB

Release files / wigm_fastapi_offline-1.6.0.tar.gz

Download URL wigm_fastapi_offline-1.6.0.tar.gz
Size 750.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0d906c26b821d8b849349804c193e87c21445f74997027751a2730d428119fab
BLAKE2b-256 checksum
How to use checksums
cd82a79cb5553072dcdc1200a559c4690fb4d343678ff5eee47427b3321cd41b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.6

Release files / wigm_fastapi_offline-1.6.0-py3-none-any.whl

Download URL wigm_fastapi_offline-1.6.0-py3-none-any.whl
Size 752.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3391445818551893bdc8b65eaa1a1b07aed2fa0706fe66d6d2d7b823a6f822b8
BLAKE2b-256 checksum
How to use checksums
f9a65fff35eea39f2487d4d3edb223c1828f2812a7ea5db510b5a5417fdfbe8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.6

Release history Release notifications | RSS feed

This release

1.6.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page