优化入口逻辑
This commit is contained in:
@@ -3,13 +3,3 @@ ReelForge API Layer
|
||||
|
||||
FastAPI-based REST API for video generation services.
|
||||
"""
|
||||
|
||||
# Lazy import to avoid loading dependencies until needed
|
||||
def get_app():
|
||||
"""Get FastAPI app instance (lazy loading)"""
|
||||
from api.app import app
|
||||
return app
|
||||
|
||||
|
||||
__all__ = ["get_app"]
|
||||
|
||||
|
||||
35
api/app.py
35
api/app.py
@@ -2,8 +2,15 @@
|
||||
ReelForge FastAPI Application
|
||||
|
||||
Main FastAPI app with all routers and middleware.
|
||||
|
||||
Run this script to start the FastAPI server:
|
||||
uv run python api/app.py
|
||||
|
||||
Or with custom settings:
|
||||
uv run python api/app.py --host 0.0.0.0 --port 8080 --reload
|
||||
"""
|
||||
|
||||
import argparse
|
||||
from contextlib import asynccontextmanager
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
@@ -124,10 +131,32 @@ async def root():
|
||||
if __name__ == "__main__":
|
||||
import uvicorn
|
||||
|
||||
# Parse command line arguments
|
||||
parser = argparse.ArgumentParser(description="Start ReelForge API Server")
|
||||
parser.add_argument("--host", default="0.0.0.0", help="Host to bind to")
|
||||
parser.add_argument("--port", type=int, default=8000, help="Port to bind to")
|
||||
parser.add_argument("--reload", action="store_true", help="Enable auto-reload")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# Print startup banner
|
||||
print(f"""
|
||||
╔══════════════════════════════════════════════════════════════╗
|
||||
║ ReelForge API Server ║
|
||||
╚══════════════════════════════════════════════════════════════╝
|
||||
|
||||
Starting server at http://{args.host}:{args.port}
|
||||
API Docs: http://{args.host}:{args.port}/docs
|
||||
ReDoc: http://{args.host}:{args.port}/redoc
|
||||
|
||||
Press Ctrl+C to stop the server
|
||||
""")
|
||||
|
||||
# Start server
|
||||
uvicorn.run(
|
||||
"api.app:app",
|
||||
host=api_config.host,
|
||||
port=api_config.port,
|
||||
reload=api_config.reload,
|
||||
host=args.host,
|
||||
port=args.port,
|
||||
reload=args.reload,
|
||||
)
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ fi
|
||||
|
||||
# Start Streamlit in background with nohup
|
||||
echo "🚀 Starting ReelForge Web UI in background..."
|
||||
nohup uv run streamlit run web.py --server.port $PORT > nohup.out 2>&1 &
|
||||
nohup uv run streamlit run web/app.py --server.port $PORT > nohup.out 2>&1 &
|
||||
|
||||
# Wait a moment and check if the process started
|
||||
sleep 2
|
||||
|
||||
46
start_api.py
46
start_api.py
@@ -1,46 +0,0 @@
|
||||
"""
|
||||
Start ReelForge API Server
|
||||
|
||||
Run this script to start the FastAPI server:
|
||||
uv run python start_api.py
|
||||
|
||||
Or with custom settings:
|
||||
uv run python start_api.py --host 0.0.0.0 --port 8080 --reload
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import uvicorn
|
||||
|
||||
|
||||
def main():
|
||||
"""Start API server"""
|
||||
parser = argparse.ArgumentParser(description="Start ReelForge API Server")
|
||||
parser.add_argument("--host", default="0.0.0.0", help="Host to bind to")
|
||||
parser.add_argument("--port", type=int, default=8000, help="Port to bind to")
|
||||
parser.add_argument("--reload", action="store_true", help="Enable auto-reload")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
print(f"""
|
||||
╔══════════════════════════════════════════════════════════════╗
|
||||
║ ReelForge API Server ║
|
||||
╚══════════════════════════════════════════════════════════════╝
|
||||
|
||||
Starting server at http://{args.host}:{args.port}
|
||||
API Docs: http://{args.host}:{args.port}/docs
|
||||
ReDoc: http://{args.host}:{args.port}/redoc
|
||||
|
||||
Press Ctrl+C to stop the server
|
||||
""")
|
||||
|
||||
uvicorn.run(
|
||||
"api.app:app",
|
||||
host=args.host,
|
||||
port=args.port,
|
||||
reload=args.reload,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -15,5 +15,5 @@ if [ ! -f config.yaml ]; then
|
||||
fi
|
||||
|
||||
# Start Streamlit
|
||||
uv run streamlit run web.py
|
||||
uv run streamlit run web/app.py
|
||||
|
||||
|
||||
@@ -722,3 +722,4 @@ def main():
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user