Skip to main content

FastAPI without reliance on CDNs for docs

Project description

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, and favicon_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.

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


Download files

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

Source Distribution

fastapi_offline-1.3.2.tar.gz (664.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastapi_offline-1.3.2-py3-none-any.whl (668.3 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_offline-1.3.2.tar.gz.

File metadata

  • Download URL: fastapi_offline-1.3.2.tar.gz
  • Upload date:
  • Size: 664.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/3.10.0 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.8

File hashes

Hashes for fastapi_offline-1.3.2.tar.gz
Algorithm Hash digest
SHA256 1b174588604c7bdc70cd0da6a992c6a814a832f81be62571b90d3c0e76aba4a5
MD5 9a2d636792a9040f28ea7e5bd8c0e098
BLAKE2b-256 dbad1dcfc35b9dc73609ca0164bbaea21fe57a4b68ab53a2a0ff21d6ec4cbd6d

See more details on using hashes here.

File details

Details for the file fastapi_offline-1.3.2-py3-none-any.whl.

File metadata

  • Download URL: fastapi_offline-1.3.2-py3-none-any.whl
  • Upload date:
  • Size: 668.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/3.10.0 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.8

File hashes

Hashes for fastapi_offline-1.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 58dba20e72c400eab770c48631b5a34d936cf94c2d2b87e51ff385122a0ca240
MD5 216e207a83f179d32e530cb76bdc3fa4
BLAKE2b-256 492d51250f891a221278e502d13f8549d3c5ce1aca31e2dec27168c76cf372be

See more details on using hashes here.

Supported by

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