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

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastapi_offline-1.7.7.tar.gz
  • Upload date:
  • Size: 777.7 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.7.tar.gz
Algorithm Hash digest
SHA256 aeeabe67dd40f867ab0fe64dd8de742949e36ba5f3ac6aeb055baef274ed91d0
MD5 63b19d27a4afa626a77e554854edef7d
BLAKE2b-256 15a5f650b565354d38f98211683a7b5c3578d450848421444799cb51da8e562f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastapi_offline-1.7.7-py3-none-any.whl
Algorithm Hash digest
SHA256 60c8399fd7d3e3b01510e14468709e3dea1a0e773ef920372d057392d736a1f9
MD5 71447d2457ab261d5a03500aefcf20b9
BLAKE2b-256 8dde808ff88dac73c97ad32c653f92f6751ea5a0a211ae1dffd471125e63a31e

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