From f1d46c2555c54de0419451f225e782aa62b2ea58 Mon Sep 17 00:00:00 2001 From: continuist Date: Sat, 29 Mar 2025 21:31:08 -0400 Subject: [PATCH] First commit --- Dockerfile | 15 +++++++++++++++ app/app.py | 7 +++++++ pytest.ini | 3 +++ requirements.txt | 2 ++ start.py | 1 + tests/test_app.py | 13 +++++++++++++ 6 files changed, 41 insertions(+) create mode 100644 Dockerfile create mode 100644 app/app.py create mode 100644 pytest.ini create mode 100644 requirements.txt create mode 100644 start.py create mode 100644 tests/test_app.py diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d53caf6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM python:3.12 + +MAINTAINER continuist + +WORKDIR /app + +COPY requirements.txt requirements.txt +RUN pip3 install -r requirements.txt + +COPY ./start.py . +COPY ./app ./app + +EXPOSE 5000 + +CMD ["gunicorn", "--bind", "0.0.0.0:5000", "start:app"] diff --git a/app/app.py b/app/app.py new file mode 100644 index 0000000..5f6cfc0 --- /dev/null +++ b/app/app.py @@ -0,0 +1,7 @@ +from flask import Flask + +app = Flask(__name__) + +@app.route("/") +def index(): + return {"Hello": "World"} diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..4584de7 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +testpaths = tests +pythonpath = . diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..f163f4d --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +flask +gunicorn \ No newline at end of file diff --git a/start.py b/start.py new file mode 100644 index 0000000..a063340 --- /dev/null +++ b/start.py @@ -0,0 +1 @@ +from app.app import app diff --git a/tests/test_app.py b/tests/test_app.py new file mode 100644 index 0000000..c81f2ce --- /dev/null +++ b/tests/test_app.py @@ -0,0 +1,13 @@ +import pytest +from app.app import app + +@pytest.fixture +def client(): + app.config['TESTING'] = True + with app.test_client() as client: + yield client + +def test_index(client): + rv = client.get('/') + assert rv.status_code == 200 + assert rv.get_json() == {"Hello": "World"}