diff options
| author | jerome <jerome@xlinfo.fr> | 2026-02-24 13:18:28 +0100 |
|---|---|---|
| committer | jerome <jerome@xlinfo.fr> | 2026-02-24 13:18:28 +0100 |
| commit | 93febd4968ebbf0f5a90989bbe11abcaaafcdbd1 (patch) | |
| tree | 27969e7c656077601e31da2b589b3031bc201f32 /app | |
| download | helloflask-93febd4968ebbf0f5a90989bbe11abcaaafcdbd1.tar.gz helloflask-93febd4968ebbf0f5a90989bbe11abcaaafcdbd1.zip | |
Diffstat (limited to 'app')
| -rw-r--r-- | app/app.py | 19 | ||||
| -rw-r--r-- | app/templates/index.html | 11 | ||||
| -rw-r--r-- | app/templates/register.html | 14 |
3 files changed, 44 insertions, 0 deletions
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 @@ +<!DOCTYPE html> +<html lang="fr"> + <head> + <meta charset="UTF-8"> + <title>Hello {{ name }}</title> + </head> + <body> + <h1>Hello {{ name }}</h1> + <p>From {{ host }}</p> + </body> +</html> 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 @@ +<!DOCTYPE html> +<html lang="fr"> +<head> + <meta charset="UTF-8"> + <title>Register</title> +</head> +<body> + <h1>Register</h1> + <form action="{{ url_for('index') }}" method="POST"> + <input type="text" name="username" placeholder="Username" required> + <button type="submit">Valider</button> + </form> +</body> +</html> |
