From 08358252fa7d93ff6031f1dae413b4386d4d6fc8 Mon Sep 17 00:00:00 2001 From: Emeline Nerot Date: Wed, 19 Mar 2025 09:03:00 +0000 Subject: [PATCH] =?UTF-8?q?T=C3=A9l=C3=A9verser=20les=20fichiers=20vers=20?= =?UTF-8?q?"Web"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Web/Dockerfile | 10 ++++++++++ Web/Dockerfile~ | Bin 0 -> 1024 bytes Web/app.py | 28 ++++++++++++++++++++++++++++ Web/requirements.txt | 2 ++ 4 files changed, 40 insertions(+) create mode 100644 Web/Dockerfile create mode 100644 Web/Dockerfile~ create mode 100644 Web/app.py create mode 100644 Web/requirements.txt diff --git a/Web/Dockerfile b/Web/Dockerfile new file mode 100644 index 0000000..d38282a --- /dev/null +++ b/Web/Dockerfile @@ -0,0 +1,10 @@ +FROM python:3.9 + +WORKDIR /app + +COPY requirements.txt requirements.txt +RUN pip install -r requirements.txt + +COPY . . + +CMD ["python", "app.py"] diff --git a/Web/Dockerfile~ b/Web/Dockerfile~ new file mode 100644 index 0000000000000000000000000000000000000000..06d7405020018ddf3cacee90fd4af10487da3d20 GIT binary patch literal 1024 ScmZQz7zLvtFd70QH3R?z00031 literal 0 HcmV?d00001 diff --git a/Web/app.py b/Web/app.py new file mode 100644 index 0000000..5f1c19f --- /dev/null +++ b/Web/app.py @@ -0,0 +1,28 @@ +from flask import Flask +import os +import psycopg2 + +app = Flask(__name__) + +DATABASE_URL = os.getenv("DATABASE_URL", "postgresql://user:password@db:5432/mydatabase") + +@app.route('/') +def home(): + return "This is my application!" + +@app.route('/db-test') +def db_test(): + try: + conn = psycopg2.connect(DATABASE_URL) + cur = conn.cursor() + cur.execute("SELECT 'Database connection successful!'") + message = cur.fetchone()[0] + cur.close() + conn.close() + return message + except Exception as e: + return f"Database connection failed: {e}" + +if __name__ == '__main__': + app.run(host='0.0.0.0', port=5000) + diff --git a/Web/requirements.txt b/Web/requirements.txt new file mode 100644 index 0000000..c8dc5ff --- /dev/null +++ b/Web/requirements.txt @@ -0,0 +1,2 @@ +flask +psycopg2