File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ Once everything is set up:
126126
127127 ``` bash
128128 cd backend
129- uv run main.py
129+ uv run main.py --port 8000
130130 ```
131131
132132 The backend server will start on http://localhost:8000 . You can verify it's running by visiting http://localhost:8000/api/v1/health in your browser.
Original file line number Diff line number Diff line change 11from fastapi import FastAPI
22from fastapi .middleware .cors import CORSMiddleware
33from fastapi .staticfiles import StaticFiles
4+ import argparse
45import os
56import logging
67
@@ -52,7 +53,18 @@ def health_check():
5253 return {"status" : "ok" }
5354
5455
55- # This allows the file to be run directly with `python backend/main.py`
5656if __name__ == "__main__" :
5757 import uvicorn
58- uvicorn .run ("main:app" , host = "0.0.0.0" , port = 8000 , reload = True )
58+
59+ # Set up command-line argument parsing
60+ parser = argparse .ArgumentParser (
61+ description = "Run the Visionary Lab backend server" )
62+ parser .add_argument (
63+ "--port" , type = int , help = "Port to run the server on (default: 8000 or PORT env var)" )
64+ args = parser .parse_args ()
65+
66+ # Use command-line port if specified, otherwise use environment PORT variable,
67+ # and finally fall back to default 8000
68+ port = args .port if args .port is not None else int (
69+ os .environ .get ("PORT" , 80 ))
70+ uvicorn .run ("main:app" , host = "0.0.0.0" , port = port , reload = True )
You can’t perform that action at this time.
0 commit comments