fastapi-offline


Namefastapi-offline JSON
Version 1.7.3 PyPI version JSON
download
home_pagehttps://github.com/turettn/fastapi_offline
SummaryFastAPI without reliance on CDNs for docs
upload_time2024-11-17 01:35:24
maintainerNone
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": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Neal Turett",
    "author_email": "turettn@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/90/74/c58dcb3c5767fa04cdef43c2f3dfee44678dddac3edbd39bed157a977160/fastapi_offline-1.7.3.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.3",
    "project_urls": {
        "Homepage": "https://github.com/turettn/fastapi_offline"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "03bd96f6832a3cd8e2eb7a11d13caac8293f10fb2494ba674bbb544b90b0d572",
                "md5": "5e579f11ea5d0c959bc90fd9b98a430d",
                "sha256": "224c2a81b9f074bf1000eb89ac6d2b3175b9c8c18fd4ef5ee4f96fc9d3c9c691"
            },
            "downloads": -1,
            "filename": "fastapi_offline-1.7.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5e579f11ea5d0c959bc90fd9b98a430d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 741876,
            "upload_time": "2024-11-17T01:35:22",
            "upload_time_iso_8601": "2024-11-17T01:35:22.002884Z",
            "url": "https://files.pythonhosted.org/packages/03/bd/96f6832a3cd8e2eb7a11d13caac8293f10fb2494ba674bbb544b90b0d572/fastapi_offline-1.7.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9074c58dcb3c5767fa04cdef43c2f3dfee44678dddac3edbd39bed157a977160",
                "md5": "16233384f7cc1a82063197d0b3896830",
                "sha256": "f918208c9054b878482cd5e7c4d8dc0e59e7e02523d3dba025bb32979af77101"
            },
            "downloads": -1,
            "filename": "fastapi_offline-1.7.3.tar.gz",
            "has_sig": false,
            "md5_digest": "16233384f7cc1a82063197d0b3896830",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 741394,
            "upload_time": "2024-11-17T01:35:24",
            "upload_time_iso_8601": "2024-11-17T01:35:24.470802Z",
            "url": "https://files.pythonhosted.org/packages/90/74/c58dcb3c5767fa04cdef43c2f3dfee44678dddac3edbd39bed157a977160/fastapi_offline-1.7.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-17 01:35:24",
    "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.66641s