Spaces:
Sleeping
Sleeping
Commit
·
fb8624f
1
Parent(s):
3e8f7f6
initial
Browse files- Dockerfile +4 -5
- app.py +6 -7
- requirements.txt +3 -2
Dockerfile
CHANGED
|
@@ -20,8 +20,7 @@ EXPOSE 7860
|
|
| 20 |
# Define environment variable
|
| 21 |
ENV NAME World
|
| 22 |
|
| 23 |
-
# Run
|
| 24 |
-
#
|
| 25 |
-
#
|
| 26 |
-
|
| 27 |
-
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 20 |
# Define environment variable
|
| 21 |
ENV NAME World
|
| 22 |
|
| 23 |
+
# Run the application with Uvicorn
|
| 24 |
+
# For Hugging Face Spaces compatibility, we use the module:app format
|
| 25 |
+
# and specify port 7860
|
| 26 |
+
CMD ["python", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
app.py
CHANGED
|
@@ -50,10 +50,9 @@ async def handle_request(request: Request):
|
|
| 50 |
|
| 51 |
return JSONResponse(content={"status": "success", "message": "Request received and logged."}, status_code=200)
|
| 52 |
|
| 53 |
-
#
|
| 54 |
-
#
|
| 55 |
-
|
| 56 |
-
#
|
| 57 |
-
#
|
| 58 |
-
|
| 59 |
-
# uvicorn.run(app, host="0.0.0.0", port=8000)
|
|
|
|
| 50 |
|
| 51 |
return JSONResponse(content={"status": "success", "message": "Request received and logged."}, status_code=200)
|
| 52 |
|
| 53 |
+
# This block allows direct execution of the app for local debugging
|
| 54 |
+
# and ensures compatibility with Hugging Face Spaces
|
| 55 |
+
if __name__ == "__main__":
|
| 56 |
+
# Hugging Face Spaces expects the app on port 7860
|
| 57 |
+
# Using 0.0.0.0 to be accessible externally
|
| 58 |
+
uvicorn.run("app:app", host="0.0.0.0", port=7860, log_level="info")
|
|
|
requirements.txt
CHANGED
|
@@ -1,2 +1,3 @@
|
|
| 1 |
-
fastapi
|
| 2 |
-
uvicorn[standard]
|
|
|
|
|
|
| 1 |
+
fastapi==0.104.1
|
| 2 |
+
uvicorn[standard]==0.23.2
|
| 3 |
+
pydantic==2.4.2
|