From 07026dfc37c886414979e382d86d8e0d64e34f06 Mon Sep 17 00:00:00 2001 From: Ludwig Lehnert Date: Fri, 14 Feb 2025 20:54:05 +0100 Subject: [PATCH] initial commit --- .gitignore | 2 ++ Dockerfile | 18 ++++++++++++++++++ requirements.txt | 2 ++ server.py | 19 +++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 requirements.txt create mode 100644 server.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..928bcdc --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +venv/ + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..10e158a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +# Use an official Python image as the base +FROM python:3.10 + +# Set the working directory +WORKDIR /app + +# Copy the application files +COPY server.py /app/ +COPY requirements.txt /app/ + +# Install dependencies +RUN pip install --no-cache-dir -r requirements.txt + +# Expose the application port +EXPOSE 8000 + +# Run the FastAPI application using Uvicorn +CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "8000"] diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..97dc7cd --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +fastapi +uvicorn diff --git a/server.py b/server.py new file mode 100644 index 0000000..2af88c9 --- /dev/null +++ b/server.py @@ -0,0 +1,19 @@ +from fastapi import FastAPI, Request +import uvicorn + +app = FastAPI() + + +@app.get("/") +def read_root(): + return {"message": "Server is running!"} + + +@app.post("/") +async def receive_data(request: Request): + data = await request.json() + print(data) + return {"received_data": data} + +if __name__ == "__main__": + uvicorn.run(app, host="0.0.0.0", port=8000)