-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathquizr.py
53 lines (39 loc) · 1.08 KB
/
quizr.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
42
43
44
45
46
47
48
49
50
51
52
53
# -*- coding: utf-8 -*-
"""
Quizr - a quiz application created with Flask.
"""
import os
from flask import Flask, session, request, render_template, redirect, url_for
# create app and initialize config
app = Flask(__name__)
app.config.update(dict(
DEBUG=True,
SECRET_KEY='development key',
))
app.config.from_envvar('QUIZR_SETTINGS', silent=True)
@app.route('/', methods=['GET', 'POST'])
def welcome_page():
"""
Welcome page - quiz info and username form.
"""
username = session.get('username')
if request.method == 'POST':
if not username:
username = session['username'] = request.form['username']
if username:
return redirect(url_for('question_page'))
return render_template('welcome.html', username=username)
@app.route('/pytanie', methods=['GET', 'POST'])
def question_page():
"""
Quiz question page - show question, handle answer.
"""
# ToDo
@app.route('/wynik')
def result_page():
"""
Last page - show results.
"""
# ToDo
if __name__ == '__main__':
app.run(host="0.0.0.0")