@@ -111,6 +111,7 @@ async def lifespan(app: FastAPI):
111111 observer .stop ()
112112 observer .join ()
113113
114+
114115app = FastAPI (lifespan = lifespan )
115116app .secret_key = os .getenv ("PYTHONWEBIO_SECRET_KEY" , "" )
116117app .state .cli_script_config = None
@@ -306,21 +307,35 @@ async def http_exception_handler(request: Request, exc: HTTPException):
306307 If running python_web_io/main.py directly (instead of via uvicorn with an entrypoint), accept CLI arguments.
307308 Ideal for quickly testing capabilities without creating `.envrc` or `.pythonwebio/config.toml` files.
308309 """
309-
310+
310311 import argparse
311312 import uvicorn
312313
313314 def parse_command_line_arguments ():
314315 parser = argparse .ArgumentParser ()
315- parser .add_argument ("--script" , type = str , default = "default_value1" , help = "Set the python script (override `config.toml` settings) (format: e.g.:`path/to/file.py:main`)." )
316- parser .add_argument ("--config" , type = str , default = ".pythonwebio/config.toml" , help = "Set the `config.toml` filepath directly (default: `.pythonwebio/config.toml`)." )
317- parser .add_argument ("--host" , type = str , default = "localhost" , help = "Host for uvicorn server." )
318- parser .add_argument ("--port" , type = int , default = 8000 , help = "Port for uvicorn server." )
316+ parser .add_argument (
317+ "--script" ,
318+ type = str ,
319+ default = "default_value1" ,
320+ help = "Set the python script (override `config.toml` settings) (format: e.g.:`path/to/file.py:main`)." ,
321+ )
322+ parser .add_argument (
323+ "--config" ,
324+ type = str ,
325+ default = ".pythonwebio/config.toml" ,
326+ help = "Set the `config.toml` filepath directly (default: `.pythonwebio/config.toml`)." ,
327+ )
328+ parser .add_argument (
329+ "--host" , type = str , default = "localhost" , help = "Host for uvicorn server."
330+ )
331+ parser .add_argument (
332+ "--port" , type = int , default = 8000 , help = "Port for uvicorn server."
333+ )
319334 return parser .parse_args ()
320335
321336 # Read command-line arguments and set app.state values
322337 args = parse_command_line_arguments ()
323338 app .state .cli_script_config = args .script
324339 app .state .config_path = args .config
325340
326- uvicorn .run (app , host = args .host , port = args .port )
341+ uvicorn .run (app , host = args .host , port = args .port )
0 commit comments