Spaces:
Sleeping
Sleeping
File size: 926 Bytes
c431adc 8103ea6 c431adc d5455f4 c431adc d5455f4 c431adc d5455f4 c431adc d5455f4 c431adc d5455f4 c431adc d5455f4 c431adc d5455f4 c431adc d5455f4 c431adc d5455f4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
import os
import threading
import time
import uvicorn
from optipfair_backend import app as fastapi_app
from optipfair_frontend import create_interface
def run_fastapi():
"""Run FastAPI backend in a separate thread"""
uvicorn.run(fastapi_app, host="0.0.0.0", port=8000, log_level="info")
def main():
"""Main function to start both FastAPI and Gradio"""
# Start FastAPI in background thread
fastapi_thread = threading.Thread(target=run_fastapi, daemon=True)
fastapi_thread.start()
# Wait a moment for FastAPI to start
print("π Starting FastAPI backend...")
time.sleep(3)
# Create and launch Gradio interface
print("π¨ Starting Gradio frontend...")
interface = create_interface()
# Launch configuration for HF Spaces
interface.launch(
server_name="0.0.0.0", server_port=7860, share=False, show_error=True
)
if __name__ == "__main__":
main()
|