File tree Expand file tree Collapse file tree
src/where_the_plow/static Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ """Dev CLI for where-the-plow."""
2+
3+ import subprocess
4+ import sys
5+
6+ COMMANDS = {
7+ "dev" : "Run uvicorn in development mode with auto-reload" ,
8+ "start" : "Run uvicorn in production mode" ,
9+ }
10+
11+ APP = "where_the_plow.main:app"
12+
13+
14+ def dev ():
15+ subprocess .run (
16+ [
17+ sys .executable ,
18+ "-m" ,
19+ "uvicorn" ,
20+ APP ,
21+ "--reload" ,
22+ "--host" ,
23+ "0.0.0.0" ,
24+ "--port" ,
25+ "8000" ,
26+ ],
27+ env = {** __import__ ("os" ).environ , "DB_PATH" : "./data/plow.db" },
28+ )
29+
30+
31+ def start ():
32+ subprocess .run (
33+ [
34+ sys .executable ,
35+ "-m" ,
36+ "uvicorn" ,
37+ APP ,
38+ "--host" ,
39+ "0.0.0.0" ,
40+ "--port" ,
41+ "8000" ,
42+ ],
43+ )
44+
45+
46+ def usage ():
47+ print ("Usage: uv run cli.py <command>\n " )
48+ print ("Commands:" )
49+ for name , desc in COMMANDS .items ():
50+ print (f" { name :10s} { desc } " )
51+ sys .exit (1 )
52+
53+
54+ def main ():
55+ if len (sys .argv ) < 2 or sys .argv [1 ] not in COMMANDS :
56+ usage ()
57+
58+ cmd = sys .argv [1 ]
59+ {"dev" : dev , "start" : start }[cmd ]()
60+
61+
62+ if __name__ == "__main__" :
63+ main ()
Original file line number Diff line number Diff line change 11services :
2- app :
2+ plow :
33 build : .
44 ports :
55 - " 127.0.0.1:8000:8000"
@@ -8,4 +8,3 @@ services:
88 environment :
99 - DB_PATH=/data/plow.db
1010 - POLL_INTERVAL=6
11- restart : unless-stopped
You can’t perform that action at this time.
0 commit comments