Spaces:
Runtime error
Runtime error
feat: expose port 8080 in Dockerfile and update application entry point
Browse files- Dockerfile +1 -0
- README.md +13 -0
- src/modules/api/app.py +4 -4
- src/modules/api/index.py +8 -4
Dockerfile
CHANGED
|
@@ -32,6 +32,7 @@ ENTRYPOINT []
|
|
| 32 |
|
| 33 |
RUN python setup.py
|
| 34 |
|
|
|
|
| 35 |
# Run the FastAPI application by default
|
| 36 |
# Uses `fastapi dev` to enable hot-reloading when the `watch` sync occurs
|
| 37 |
# Uses `--host 0.0.0.0` to allow access from outside the container
|
|
|
|
| 32 |
|
| 33 |
RUN python setup.py
|
| 34 |
|
| 35 |
+
EXPOSE 8080
|
| 36 |
# Run the FastAPI application by default
|
| 37 |
# Uses `fastapi dev` to enable hot-reloading when the `watch` sync occurs
|
| 38 |
# Uses `--host 0.0.0.0` to allow access from outside the container
|
README.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# Python Project Template
|
| 2 |
|
| 3 |
A modern Python project template with best practices for development, testing, and deployment.
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Python Project Template
|
| 3 |
+
emoji: 🟧
|
| 4 |
+
colorFrom: yellow
|
| 5 |
+
colorTo: purple
|
| 6 |
+
sdk: docker
|
| 7 |
+
tags:
|
| 8 |
+
- Python
|
| 9 |
+
fullwidth: true
|
| 10 |
+
license: mit
|
| 11 |
+
app_port: 8080
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
# Python Project Template
|
| 15 |
|
| 16 |
A modern Python project template with best practices for development, testing, and deployment.
|
src/modules/api/app.py
CHANGED
|
@@ -5,11 +5,10 @@ from fastapi.middleware.cors import CORSMiddleware
|
|
| 5 |
|
| 6 |
from .routes import v1_router
|
| 7 |
|
|
|
|
| 8 |
def create_app() -> FastAPI:
|
| 9 |
"""Create and configure the FastAPI application."""
|
| 10 |
-
app = FastAPI(
|
| 11 |
-
|
| 12 |
-
)
|
| 13 |
|
| 14 |
# Add CORS middleware
|
| 15 |
app.add_middleware(
|
|
@@ -35,5 +34,6 @@ def create_app() -> FastAPI:
|
|
| 35 |
|
| 36 |
return app
|
| 37 |
|
|
|
|
| 38 |
# Create default app instance
|
| 39 |
-
app = create_app()
|
|
|
|
| 5 |
|
| 6 |
from .routes import v1_router
|
| 7 |
|
| 8 |
+
|
| 9 |
def create_app() -> FastAPI:
|
| 10 |
"""Create and configure the FastAPI application."""
|
| 11 |
+
app = FastAPI()
|
|
|
|
|
|
|
| 12 |
|
| 13 |
# Add CORS middleware
|
| 14 |
app.add_middleware(
|
|
|
|
| 34 |
|
| 35 |
return app
|
| 36 |
|
| 37 |
+
|
| 38 |
# Create default app instance
|
| 39 |
+
app = create_app()
|
src/modules/api/index.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
| 1 |
-
import uvicorn
|
| 2 |
from .app import app as api_app
|
|
|
|
|
|
|
| 3 |
|
| 4 |
def main():
|
| 5 |
"""Main application entry point."""
|
|
@@ -8,10 +10,12 @@ def main():
|
|
| 8 |
uvicorn.run(
|
| 9 |
api_app,
|
| 10 |
host="0.0.0.0",
|
| 11 |
-
port=
|
| 12 |
reload=False,
|
| 13 |
)
|
| 14 |
except Exception as e:
|
| 15 |
-
|
| 16 |
raise
|
| 17 |
-
|
|
|
|
|
|
|
|
|
| 1 |
+
import uvicorn
|
| 2 |
from .app import app as api_app
|
| 3 |
+
import logging
|
| 4 |
+
|
| 5 |
|
| 6 |
def main():
|
| 7 |
"""Main application entry point."""
|
|
|
|
| 10 |
uvicorn.run(
|
| 11 |
api_app,
|
| 12 |
host="0.0.0.0",
|
| 13 |
+
port=8080,
|
| 14 |
reload=False,
|
| 15 |
)
|
| 16 |
except Exception as e:
|
| 17 |
+
logging.error(f"Application failed to start: {e}", exc_info=True)
|
| 18 |
raise
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
main()
|