From 93febd4968ebbf0f5a90989bbe11abcaaafcdbd1 Mon Sep 17 00:00:00 2001 From: jerome Date: Tue, 24 Feb 2026 13:18:28 +0100 Subject: commit initial --- .gitignore | 7 +++++++ Dockerfile | 13 +++++++++++++ app/app.py | 19 +++++++++++++++++++ app/templates/index.html | 11 +++++++++++ app/templates/register.html | 14 ++++++++++++++ requirements.txt | 9 +++++++++ 6 files changed, 73 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 app/app.py create mode 100644 app/templates/index.html create mode 100644 app/templates/register.html create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a7efb38 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +# Created by venv; see https://docs.python.org/3/library/venv.html +bin/ +include/ +lib/ +lib64 +pyvenv.cfg +__pycache__/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..dccc366 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +# Stage 1: Build Stage +FROM python:slim AS build +COPY requirements.txt . +RUN python -m venv /opt/venv && . /opt/venv/bin/activate && pip install --no-cache-dir -r requirements.txt + +# Stage 2: Run Stage +FROM python:slim AS run +COPY --from=build /opt/venv /opt/venv +WORKDIR /app +COPY app /app +ENV PATH="/opt/venv/bin/:$PATH" +EXPOSE 80 +CMD ["gunicorn", "--bind", "0.0.0.0:80", "app:app"] diff --git a/app/app.py b/app/app.py new file mode 100644 index 0000000..9aa9782 --- /dev/null +++ b/app/app.py @@ -0,0 +1,19 @@ +from flask import Flask, render_template, request, redirect, url_for +import platform + +app = Flask(__name__) #On créé une instance de la classe Flask + +@app.route('/', methods=['GET','POST']) +def index(): + try: + username = request.form['username'] + return render_template('index.html',name=username,host=platform.node()) + except: + return redirect(url_for('register')) + +@app.route('/register') +def register(): + return render_template('register.html') + +if __name__ == "__main__": + app.run(host='0.0.0.0',port=8000,debug=True) diff --git a/app/templates/index.html b/app/templates/index.html new file mode 100644 index 0000000..b4869d6 --- /dev/null +++ b/app/templates/index.html @@ -0,0 +1,11 @@ + + + + + Hello {{ name }} + + +

Hello {{ name }}

+

From {{ host }}

+ + diff --git a/app/templates/register.html b/app/templates/register.html new file mode 100644 index 0000000..bd39bdf --- /dev/null +++ b/app/templates/register.html @@ -0,0 +1,14 @@ + + + + + Register + + +

Register

+
+ + +
+ + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..a8ec37c --- /dev/null +++ b/requirements.txt @@ -0,0 +1,9 @@ +blinker==1.9.0 +click==8.3.1 +Flask==3.1.3 +gunicorn==25.1.0 +itsdangerous==2.2.0 +Jinja2==3.1.6 +MarkupSafe==3.0.3 +packaging==26.0 +Werkzeug==3.1.6 -- cgit v1.2.3