fastapi-offline


Namefastapi-offline JSON
Version 1.7.1 PyPI version JSON
download
home_pagehttps://github.com/turettn/fastapi_offline
SummaryFastAPI without reliance on CDNs for docs
upload_time2024-01-21 22:09:00
maintainer
docs_urlNone
authorNeal Turett
requires_python>=3.8
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": "fastapi-offline",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "",
    "author": "Neal Turett",
    "author_email": "turettn@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/7d/98/81beaccb3f4f8b1b666a628ea34a4ea3313840ab0b9d254952d1da896f35/fastapi_offline-1.7.1.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\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "FastAPI without reliance on CDNs for docs",
    "version": "1.7.1",
    "project_urls": {
        "Homepage": "https://github.com/turettn/fastapi_offline"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5d511f544b37ed8d55805a168d45fc7ece1e536940c692cca06b5bbf0fe8d372",
                "md5": "95f427185a4fb1cd8b84fda396797da1",
                "sha256": "ea79fbe9ecac4f54acd68ebfab955cc6ed8f51382b0858f1923ab83f775c1c23"
            },
            "downloads": -1,
            "filename": "fastapi_offline-1.7.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "95f427185a4fb1cd8b84fda396797da1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 730624,
            "upload_time": "2024-01-21T22:08:57",
            "upload_time_iso_8601": "2024-01-21T22:08:57.898056Z",
            "url": "https://files.pythonhosted.org/packages/5d/51/1f544b37ed8d55805a168d45fc7ece1e536940c692cca06b5bbf0fe8d372/fastapi_offline-1.7.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7d9881beaccb3f4f8b1b666a628ea34a4ea3313840ab0b9d254952d1da896f35",
                "md5": "f2ad9b21eb2d73374440db2c21af130f",
                "sha256": "4974e55f903dc7b13bc84722a4cd6edeada4021f7061f07dbf241e1617d34aae"
            },
            "downloads": -1,
            "filename": "fastapi_offline-1.7.1.tar.gz",
            "has_sig": false,
            "md5_digest": "f2ad9b21eb2d73374440db2c21af130f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 729407,
            "upload_time": "2024-01-21T22:09:00",
            "upload_time_iso_8601": "2024-01-21T22:09:00.638903Z",
            "url": "https://files.pythonhosted.org/packages/7d/98/81beaccb3f4f8b1b666a628ea34a4ea3313840ab0b9d254952d1da896f35/fastapi_offline-1.7.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-21 22:09:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "turettn",
    "github_project": "fastapi_offline",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "fastapi-offline"
}
        
Elapsed time: 0.20285s