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, 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


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.7.5.tar.gz (733.5 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.7.5-py3-none-any.whl (733.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastapi_offline-1.7.5.tar.gz
  • Upload date:
  • Size: 733.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for fastapi_offline-1.7.5.tar.gz
Algorithm Hash digest
SHA256 07a58cb8d8fab68ba625698414b4cac833bb2d94d82dc0fbc2a8519bee7af87d
MD5 e6cd92870f65d8032d00a1cc02ba1dc9
BLAKE2b-256 72fd035099c1ffc1ecc8f1490046f8ad7602d8c2fa469c302d66bc0a825dc5bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastapi_offline-1.7.5-py3-none-any.whl
Algorithm Hash digest
SHA256 00369632d604e8156b9ca9ab9c65e58ad8beff83d1ffc7bdbcec4a86173d51b4
MD5 cfc4b540bfb7dd19a9f3a9828a4c2009
BLAKE2b-256 7c73b262242d04326f4aee6a8fe86efb7e383eb9f2ce9e140479a9040a652cc3

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