Skip to main content

FastAPI Global variable

Project description

FastAPI Global Variable

How to use

  1. Set a variable
# user_service.py
from fastapi import FastAPI
from fastapi_global_variable import GlobalVariable

app = FastAPI(title="Application")

GlobalVariable.set('app', app)
  1. Use variable
from fastapi_global_variable import GlobalVariable

print(GlobalVariable.get_or_fail('app'))
print(GlobalVariable.get('app'))

How to test in testpypi

  1. Increase the version in pyproject.toml
  2. Run command
$ . ./build_and_test.sh

How to publish new version

  1. Increase the version in pyproject.toml
  2. Run command
$ . ./build_and_publish.sh

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_global_variable-0.0.4.tar.gz (3.8 kB view hashes)

Uploaded Source

Built Distribution

fastapi_global_variable-0.0.4-py3-none-any.whl (2.9 kB view hashes)

Uploaded Python 3

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