calcfastapi / app.py
0Learn's picture
Update app.py
69b23f1 verified
raw
history blame
699 Bytes
import uvicorn
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from backend import app as backend_app
from frontend import create_interface
import threading
# Create the main FastAPI app
app = FastAPI()
# Add CORS middleware
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Include the backend routes
app.include_router(backend_app)
# Create the Gradio interface
iface = create_interface()
# Mount the Gradio app
app = gr.mount_gradio_app(app, iface, path="/")
if __name__ == "__main__":
# Run the FastAPI server
uvicorn.run(app, host="0.0.0.0", port=7860)