generated from recursivezero/template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
42 lines (33 loc) · 899 Bytes
/
cli.py
File metadata and controls
42 lines (33 loc) · 899 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import click
import uvicorn
from app import __version__
@click.group(invoke_without_command=True)
@click.option("--version", is_flag=True, help="Show Tiny version and exit.")
@click.pass_context
def main(ctx, version):
"""Tiny command-line interface."""
if version:
click.echo(__version__)
ctx.exit()
@main.command()
def dev():
"""Run Tiny UI in development mode."""
click.echo("🛠 Running Tiny UI (FastAPI)")
uvicorn.run(
"app.main:app",
host="127.0.0.1",
port=8000,
reload=True,
)
@main.command()
def api():
"""Run Tiny API server (FastAPI + uvicorn)."""
click.echo(f"🚀Tiny API server v{__version__}")
uvicorn.run(
"app.api.fast_api:app",
host="127.0.0.1",
port=8001,
reload=True,
)
if __name__ == "__main__":
main()