forked from gregraudenbush/Flask-Debug-Quiz-Py3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
executable file
·41 lines (26 loc) · 1.01 KB
/
server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from flask import Flask, request, redirect, session, flash, render_template
app = Flask(__name__)
app.secret_key = "unicorns"
####################
#Welcome to the Flask Debug Quiz
#Fix all errors, and fix the commented instructions within the index route
#Good Luck Hackers!
####################
@app.route('/')
def index():
if "info" not in session:
session['info'] = ""
##########################
#Important!
#Session['info'] appears as an Array on the front page.
#Add the a loop on index.html to display each index of the array on a separate line
#########################
return render_template("index.html", info = session['info'])
@app.route("/form", methods=["POST"])
def form():
if len(request.form['FirstName']) < 1 or len(request.form['LastName']) < 1:
flash("Please Complete Form")
else:
session['info'] = [request.form["FirstName"], request.form['LastName'], request.form['FaveSnack']]
return redirect('/')
app.run(debug=True)