2023-10-29 19:29:25 +01:00
|
|
|
import uvicorn
|
|
|
|
|
|
2025-03-25 09:48:40 +01:00
|
|
|
from app.api.config import config
|
|
|
|
|
|
2023-10-29 19:29:25 +01:00
|
|
|
import click # isort:skip
|
|
|
|
|
|
2025-02-16 20:35:21 +01:00
|
|
|
|
2023-10-29 19:29:25 +01:00
|
|
|
@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")
|
2025-02-16 20:35:21 +01:00
|
|
|
@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):
|
2026-07-03 15:30:17 +02:00
|
|
|
"""Launched with `uv run api` at root level"""
|
2025-02-16 20:35:21 +01:00
|
|
|
|
|
|
|
|
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)
|
2023-10-29 19:29:25 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
main()
|