mirror of
https://github.com/fusion44/blitz_api.git
synced 2026-08-15 12:10:12 +02:00
If the environment variable BAPI_ENV_PATH is set, the config system will try to read configs from the given path instead of .env in pwd If no file is found .env in pwd will be used as a fallback Env variables will always override settings in .env files.
33 lines
822 B
Python
33 lines
822 B
Python
import uvicorn
|
|
|
|
import click # isort:skip
|
|
|
|
from app.api.config import config
|
|
|
|
|
|
@click.command()
|
|
@click.option("--port", default="5000", help="Port to run Blitz API on")
|
|
@click.option("--host", default="127.0.0.1", help="Host to run Blitz API on")
|
|
@click.option(
|
|
"--root_path",
|
|
default=None,
|
|
help="Set the ASGI 'root_path' for applications submounted below a given URL path.",
|
|
)
|
|
def main(port, host, root_path):
|
|
"""Launched with `poetry run api` at root level"""
|
|
|
|
p = ""
|
|
if root_path is not None and root_path != "":
|
|
p = root_path
|
|
else:
|
|
p = str(config("BAPI_ROOT_PATH", default=""))
|
|
|
|
if p == "/":
|
|
root_path = ""
|
|
|
|
print(f"launching with {host}:{port}{p}")
|
|
uvicorn.run("app.main:app", port=port, host=host, root_path=p)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|