Verlinkung mit finaler Seite eingebaut

This commit is contained in:
2024-01-14 22:08:10 +01:00
parent a1ee5f3ea0
commit fdac7b05ea
4 changed files with 48 additions and 7 deletions

17
app.py
View File

@@ -1,14 +1,27 @@
from flask import Flask, render_template from flask import Flask, render_template, request, redirect, url_for
app = Flask(__name__) app = Flask(__name__)
@app.route('/') @app.route('/', methods=['GET','POST'])
def home(): def home():
if request.method == 'GET':
return render_template('index.html') return render_template('index.html')
if request.method == 'POST':
return redirect(url_for('form'))
@app.route ('/form', methods=['GET','POST']) @app.route ('/form', methods=['GET','POST'])
def form(): def form():
if request.method == 'GET':
return render_template('form.html') return render_template('form.html')
if request.method == 'POST':
user = request.form['name']
return redirect(url_for('submitted'))
@app.route ('/submitted')
def submitted():
return render_template('submitted.html')
if __name__ == '__main__': if __name__ == '__main__':

View File

@@ -5,6 +5,16 @@
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<form action='#' method='post'>
<br>
<p> Name:</p>
<p><input type='text' name='name' /></p>
<p> Email:</p>
<p><input type='text' name='email' /></p>
<br>
<p><input type='submit' value='submit' /></p>
</form>
<input type="radio" class="btn-check" name="options-base" id="option5" autocomplete="off" checked> <input type="radio" class="btn-check" name="options-base" id="option5" autocomplete="off" checked>
<label class="btn" for="option5">Fuck yes!</label> <label class="btn" for="option5">Fuck yes!</label>
@@ -12,7 +22,7 @@
<label class="btn" for="option6">Fuck no!</label> <label class="btn" for="option6">Fuck no!</label>
<input type="radio" class="btn-check" name="options-base" id="option7" autocomplete="off"> <input type="radio" class="btn-check" name="options-base" id="option7" autocomplete="off">
<label class="btn" for="option7">Fuck you!</label> <label class="btn" for="option7">Fuck you!</label><br><br>
<button type="button" class="btn btn-primary">Submit</button> <button type="button" class="btn btn-primary">Submit</button>
{% endblock %} {% endblock %}

View File

@@ -5,5 +5,14 @@
{% endblock %} {% endblock %}
{% block content %} {% block content %}
Content: Index <br><br>
{% endblock %} Um die Frage vorab zu beantworten: "WTF... hasch du di wirklich in Web-programmierung inkl. CSS und Javascript eingelesen <br>, gelernt des ganze Backend mit Python zu schreiben und des ganze auf deinem eigenen Server deployed... nur für den Joke?!"
<br><br>
<h3>JA</h3>
<br>
<form action='#' method='post'>
<p> Hier geht es zum Antragformular:</p>
<br>
<p><input type='submit' value='Zum Formular' /></p>
</form>
{% endblock %}

9
templates/submitted.html Normal file
View File

@@ -0,0 +1,9 @@
{% extends "base.html" %}
{% block title %}
Title: Submitted
{% endblock %}
{% block content %}
Formular eingereicht!
{% endblock %}