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

wigm_fastapi_offline-1.6.0.tar.gz (750.7 kB view details)

Uploaded Source

Built Distribution

wigm_fastapi_offline-1.6.0-py3-none-any.whl (752.8 kB view details)

Uploaded Python 3

File details

Details for the file wigm_fastapi_offline-1.6.0.tar.gz.

File metadata

  • Download URL: wigm_fastapi_offline-1.6.0.tar.gz
  • Upload date:
  • Size: 750.7 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for wigm_fastapi_offline-1.6.0.tar.gz
Algorithm Hash digest
SHA256 0d906c26b821d8b849349804c193e87c21445f74997027751a2730d428119fab
MD5 1826fdc08cb385d8b53d65486cc63473
BLAKE2b-256 cd82a79cb5553072dcdc1200a559c4690fb4d343678ff5eee47427b3321cd41b

See more details on using hashes here.

File details

Details for the file wigm_fastapi_offline-1.6.0-py3-none-any.whl.

File metadata

  • Download URL: wigm_fastapi_offline-1.6.0-py3-none-any.whl
  • Upload date:
  • Size: 752.8 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for wigm_fastapi_offline-1.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3391445818551893bdc8b65eaa1a1b07aed2fa0706fe66d6d2d7b823a6f822b8
MD5 9cc3a18093107304497512a55547ebc9
BLAKE2b-256 f9a65fff35eea39f2487d4d3edb223c1828f2812a7ea5db510b5a5417fdfbe8a

See more details on using hashes here.

Supported by

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