Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -235,6 +235,7 @@
|
|
| 235 |
# # http://localhost:8000/docs#/
|
| 236 |
# # (.venv) PS C:\Users\antoi\Documents\Work_Learn\Labeling-Deploy\FastAPI> uvicorn main:app --host 0.0.0.0 --port 8000 --workers 1
|
| 237 |
|
|
|
|
| 238 |
from fastapi import FastAPI, UploadFile, File, HTTPException
|
| 239 |
import cv2
|
| 240 |
import torch
|
|
@@ -516,6 +517,35 @@ async def index():
|
|
| 516 |
"""
|
| 517 |
)
|
| 518 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 519 |
# Lancer l'application avec uvicorn (command line)
|
| 520 |
# uvicorn main:app --reload
|
| 521 |
# http://localhost:8000/docs#/
|
|
|
|
| 235 |
# # http://localhost:8000/docs#/
|
| 236 |
# # (.venv) PS C:\Users\antoi\Documents\Work_Learn\Labeling-Deploy\FastAPI> uvicorn main:app --host 0.0.0.0 --port 8000 --workers 1
|
| 237 |
|
| 238 |
+
|
| 239 |
from fastapi import FastAPI, UploadFile, File, HTTPException
|
| 240 |
import cv2
|
| 241 |
import torch
|
|
|
|
| 517 |
"""
|
| 518 |
)
|
| 519 |
|
| 520 |
+
import logging
|
| 521 |
+
|
| 522 |
+
logging.basicConfig(level=logging.INFO)
|
| 523 |
+
logger = logging.getLogger(__name__)
|
| 524 |
+
|
| 525 |
+
@app.post("/test_connection/")
|
| 526 |
+
async def test_connection(user_name: str):
|
| 527 |
+
try:
|
| 528 |
+
# Log for debugging purposes
|
| 529 |
+
logger.info(f"Received user_name: {user_name}")
|
| 530 |
+
print(f"Received user_name: {user_name}")
|
| 531 |
+
|
| 532 |
+
# Simple response for testing purposes
|
| 533 |
+
response_message = f"Hello, {user_name}! The backend is reachable and working correctly."
|
| 534 |
+
|
| 535 |
+
# Log the response message
|
| 536 |
+
logger.info(f"Returning response: {response_message}")
|
| 537 |
+
print(f"Returning response: {response_message}")
|
| 538 |
+
|
| 539 |
+
return {
|
| 540 |
+
"message": response_message
|
| 541 |
+
}
|
| 542 |
+
|
| 543 |
+
except Exception as e:
|
| 544 |
+
logger.error(f"Error during test connection: {str(e)}")
|
| 545 |
+
print(f"Error during test connection: {str(e)}")
|
| 546 |
+
raise HTTPException(status_code=500, detail=f"Failed to connect: {str(e)}")
|
| 547 |
+
|
| 548 |
+
|
| 549 |
# Lancer l'application avec uvicorn (command line)
|
| 550 |
# uvicorn main:app --reload
|
| 551 |
# http://localhost:8000/docs#/
|