blob: b383b0db03dcc990861187da27b5d54c917548f7 (
plain)
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
|
import simplejson as json
from flask import Flask
from flask import abort, redirect, url_for
from blueprint_test import simple_page
app = Flask(__name__)
app.register_blueprint(simple_page)
#app.logger.debug('A value for debugging')
#app.logger.warning('A warning occurred (%d apples)', 42)
#app.logger.error('An error occurred')
@app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__":
app.run()
@app.route('/login', methods=['POST', 'GET'])
def login():
error = None
if request.method == 'POST':
if valid_login(request.form['username'],
request.form['password']):
return log_the_user_in(request.form['username'])
else:
error = 'Invalid username/password'
#searchword = request.args.get('key', '')
# the code below is executed if the request method
# was GET or the credentials were invalid
return render_template('login.html', error=error)
@app.route('/')
def index():
return redirect(url_for('login'))
@app.route('/login')
def login():
abort(401)
this_is_never_executed()
url_for('static', filename='style.css')
|