ira/sim-search-api/run.py

57 lines
1.2 KiB
Python

#!/usr/bin/env python3
"""
Run script for the sim-search API.
This script launches the FastAPI application using uvicorn.
"""
import argparse
import uvicorn
def parse_args():
"""Parse command line arguments."""
parser = argparse.ArgumentParser(description="Run the sim-search API")
parser.add_argument(
"--host",
type=str,
default="127.0.0.1",
help="Host to run the server on",
)
parser.add_argument(
"--port",
type=int,
default=8000,
help="Port to run the server on",
)
parser.add_argument(
"--reload",
action="store_true",
help="Enable auto-reload for development",
)
parser.add_argument(
"--debug",
action="store_true",
help="Run in debug mode",
)
return parser.parse_args()
def main():
"""Main function to run the API."""
args = parse_args()
print(f"Starting sim-search API on {args.host}:{args.port}...")
uvicorn.run(
"app.main:app",
host=args.host,
port=args.port,
reload=args.reload,
log_level="debug" if args.debug else "info",
)
if __name__ == "__main__":
main()