wigm-fastapi-offline


Namewigm-fastapi-offline JSON
Version 1.6.0 PyPI version JSON
download
home_pagehttps://github.com/turettn/fastapi_offline
SummaryFastAPI without reliance on CDNs for docs
upload_time2023-07-21 10:29:53
maintainer
docs_urlNone
authorNeal Turett
requires_python>=3.7
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Overview

[![](https://img.shields.io/pypi/v/fastapi-offline.svg)](https://pypi.python.org/pypi/fastapi-offline/)
[![Test](https://github.com/turettn/fastapi_offline/actions/workflows/test.yml/badge.svg)](https://github.com/turettn/fastapi_offline/actions/workflows/test.yml)
[![codecov](https://codecov.io/gh/turettn/fastapi_offline/branch/main/graph/badge.svg)](https://codecov.io/gh/turettn/fastapi_offline)

[FastAPI](https://fastapi.tiangolo.com/) 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](https://fastapi.tiangolo.com/advanced/extending-openapi/#self-hosting-javascript-and-css-for-docs).

# Installation

You can install this package from PyPi:

```bash
pip install fastapi-offline
```

# Example

Given the example from the [FastAPI tutorial](https://fastapi.tiangolo.com/tutorial/first-steps/):

```python
from fastapi import FastAPI

app = FastAPI()


@app.get("/")
async def root():
    return {"message": "Hello World"}
```

Simply create a `fastapi_offline.FastAPIOffline` object instead:

```python
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:

```py
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](https://swagger.io/license/)) and copyright apply to those files.
* Parts of Redoc are included in this package.  The original license ([MIT](https://github.com/Redocly/redoc/blob/master/LICENSE)) and copyright apply to those files.
* The FastAPI `favicon.png` file is included in this package.  The original license ([MIT](https://github.com/Redocly/redoc/blob/master/LICENSE)) and copyright apply to that file.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/turettn/fastapi_offline",
    "name": "wigm-fastapi-offline",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "Neal Turett",
    "author_email": "turettn@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/cd/82/a79cb5553072dcdc1200a559c4690fb4d343678ff5eee47427b3321cd41b/wigm_fastapi_offline-1.6.0.tar.gz",
    "platform": null,
    "description": "# Overview\n\n[![](https://img.shields.io/pypi/v/fastapi-offline.svg)](https://pypi.python.org/pypi/fastapi-offline/)\n[![Test](https://github.com/turettn/fastapi_offline/actions/workflows/test.yml/badge.svg)](https://github.com/turettn/fastapi_offline/actions/workflows/test.yml)\n[![codecov](https://codecov.io/gh/turettn/fastapi_offline/branch/main/graph/badge.svg)](https://codecov.io/gh/turettn/fastapi_offline)\n\n[FastAPI](https://fastapi.tiangolo.com/) 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.\n\nThis 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.\n\nUnder the hood, this simply automates the process described in the official documentation [here](https://fastapi.tiangolo.com/advanced/extending-openapi/#self-hosting-javascript-and-css-for-docs).\n\n# Installation\n\nYou can install this package from PyPi:\n\n```bash\npip install fastapi-offline\n```\n\n# Example\n\nGiven the example from the [FastAPI tutorial](https://fastapi.tiangolo.com/tutorial/first-steps/):\n\n```python\nfrom fastapi import FastAPI\n\napp = FastAPI()\n\n\n@app.get(\"/\")\nasync def root():\n    return {\"message\": \"Hello World\"}\n```\n\nSimply create a `fastapi_offline.FastAPIOffline` object instead:\n\n```python\nfrom fastapi_offline import FastAPIOffline\n\napp = FastAPIOffline()\n\n\n@app.get(\"/\")\nasync def root():\n    return {\"message\": \"Hello World\"}\n```\n\nAny 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.\n\n`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`).\n\n# Using a custom shortcut icon\n\nBy 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:\n\n```py\napp = FastAPIOffline(\n    favicon_url=\"http://my.cool.site/favicon.png\"\n)\n```\n\n# Licensing\n\n* This code is released under the MIT license.\n* Parts of Swagger are included in this package.  The original license ([Apache 2.0](https://swagger.io/license/)) and copyright apply to those files.\n* Parts of Redoc are included in this package.  The original license ([MIT](https://github.com/Redocly/redoc/blob/master/LICENSE)) and copyright apply to those files.\n* The FastAPI `favicon.png` file is included in this package.  The original license ([MIT](https://github.com/Redocly/redoc/blob/master/LICENSE)) and copyright apply to that file.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "FastAPI without reliance on CDNs for docs",
    "version": "1.6.0",
    "project_urls": {
        "Homepage": "https://github.com/turettn/fastapi_offline"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f9a65fff35eea39f2487d4d3edb223c1828f2812a7ea5db510b5a5417fdfbe8a",
                "md5": "9cc3a18093107304497512a55547ebc9",
                "sha256": "3391445818551893bdc8b65eaa1a1b07aed2fa0706fe66d6d2d7b823a6f822b8"
            },
            "downloads": -1,
            "filename": "wigm_fastapi_offline-1.6.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9cc3a18093107304497512a55547ebc9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 752817,
            "upload_time": "2023-07-21T10:29:50",
            "upload_time_iso_8601": "2023-07-21T10:29:50.311168Z",
            "url": "https://files.pythonhosted.org/packages/f9/a6/5fff35eea39f2487d4d3edb223c1828f2812a7ea5db510b5a5417fdfbe8a/wigm_fastapi_offline-1.6.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cd82a79cb5553072dcdc1200a559c4690fb4d343678ff5eee47427b3321cd41b",
                "md5": "1826fdc08cb385d8b53d65486cc63473",
                "sha256": "0d906c26b821d8b849349804c193e87c21445f74997027751a2730d428119fab"
            },
            "downloads": -1,
            "filename": "wigm_fastapi_offline-1.6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "1826fdc08cb385d8b53d65486cc63473",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 750734,
            "upload_time": "2023-07-21T10:29:53",
            "upload_time_iso_8601": "2023-07-21T10:29:53.073392Z",
            "url": "https://files.pythonhosted.org/packages/cd/82/a79cb5553072dcdc1200a559c4690fb4d343678ff5eee47427b3321cd41b/wigm_fastapi_offline-1.6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-21 10:29:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "turettn",
    "github_project": "fastapi_offline",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "wigm-fastapi-offline"
}
        
Elapsed time: 0.23049s