Add simple FastAPI backend
This commit is contained in:
12
backend/docker/Dockerfile
Normal file
12
backend/docker/Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
||||
FROM python:3.13.7-slim-bookworm
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy requirements and install Python dependencies
|
||||
COPY ./requirements.txt ./
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Copy the app code and tests
|
||||
COPY ../src ./src
|
||||
|
||||
CMD ["python", "src/main.py"]
|
||||
2
backend/requirements.txt
Normal file
2
backend/requirements.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
fastapi
|
||||
uvicorn[standard]
|
||||
11
backend/src/main.py
Normal file
11
backend/src/main.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from fastapi import FastAPI
|
||||
|
||||
app = FastAPI(title="HanchuESS Solar Backend API")
|
||||
|
||||
@app.get("/", tags=["Root"])
|
||||
def root():
|
||||
return {"message": "Welcome to the HanchuESS Solar Backend API!"}
|
||||
|
||||
if __name__ == "__main__":
|
||||
import uvicorn
|
||||
uvicorn.run(app, host="0.0.0.0", port=8050)
|
||||
8
docker-compose.yml
Normal file
8
docker-compose.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
services:
|
||||
hanchuess-solar-backend:
|
||||
build:
|
||||
context: backend
|
||||
dockerfile: docker/Dockerfile
|
||||
container_name: hanchuess-solar-backend
|
||||
ports:
|
||||
- "8050:8050"
|
||||
Reference in New Issue
Block a user