update-8
Browse files
app.py
CHANGED
|
@@ -5,9 +5,6 @@ from fastapi import FastAPI
|
|
| 5 |
from fastapi.staticfiles import StaticFiles
|
| 6 |
import tempfile
|
| 7 |
|
| 8 |
-
# Import and create the FastAPI app
|
| 9 |
-
from src.api.main import app as fastapi_app
|
| 10 |
-
|
| 11 |
# Configuration for Hugging Face integration
|
| 12 |
# When running in Hugging Face Spaces, the API will be available at the same server
|
| 13 |
API_BASE_URL = os.getenv("API_BASE_URL", "http://localhost:8000")
|
|
@@ -90,24 +87,33 @@ with gr.Blocks(title="Todo Backend API - Hugging Face Interface") as demo:
|
|
| 90 |
**Source Code:** [GitHub Repository](#)
|
| 91 |
""")
|
| 92 |
|
| 93 |
-
#
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
"
|
| 108 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
}
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
if __name__ == "__main__":
|
| 113 |
# For local development, run the combined app
|
|
|
|
| 5 |
from fastapi.staticfiles import StaticFiles
|
| 6 |
import tempfile
|
| 7 |
|
|
|
|
|
|
|
|
|
|
| 8 |
# Configuration for Hugging Face integration
|
| 9 |
# When running in Hugging Face Spaces, the API will be available at the same server
|
| 10 |
API_BASE_URL = os.getenv("API_BASE_URL", "http://localhost:8000")
|
|
|
|
| 87 |
**Source Code:** [GitHub Repository](#)
|
| 88 |
""")
|
| 89 |
|
| 90 |
+
# Create the main app and import the API routes properly to avoid circular imports
|
| 91 |
+
def create_combined_app():
|
| 92 |
+
from src.api.main import create_app
|
| 93 |
+
|
| 94 |
+
# Create the main API app
|
| 95 |
+
api_app = create_app()
|
| 96 |
+
|
| 97 |
+
# Mount the Gradio app using the proper method for newer Gradio versions
|
| 98 |
+
combined_app = gr.mount_gradio_app(api_app, demo, path="/gradio")
|
| 99 |
+
|
| 100 |
+
# Add a root redirect to guide users to the proper endpoints
|
| 101 |
+
@combined_app.get("/")
|
| 102 |
+
async def root():
|
| 103 |
+
return {
|
| 104 |
+
"message": "Todo Backend API with Gradio Interface",
|
| 105 |
+
"api_docs": "/docs",
|
| 106 |
+
"gradio_interface": "/gradio",
|
| 107 |
+
"api_endpoints": {
|
| 108 |
+
"auth": "/api/v1/auth",
|
| 109 |
+
"tasks": "/api/v1/tasks"
|
| 110 |
+
}
|
| 111 |
}
|
| 112 |
+
|
| 113 |
+
return combined_app
|
| 114 |
+
|
| 115 |
+
# Create the combined app
|
| 116 |
+
app = create_combined_app()
|
| 117 |
|
| 118 |
if __name__ == "__main__":
|
| 119 |
# For local development, run the combined app
|