summaryrefslogtreecommitdiff
path: root/share/Flask_test/test.py
diff options
context:
space:
mode:
Diffstat (limited to 'share/Flask_test/test.py')
-rw-r--r--share/Flask_test/test.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/share/Flask_test/test.py b/share/Flask_test/test.py
new file mode 100644
index 0000000..b383b0d
--- /dev/null
+++ b/share/Flask_test/test.py
@@ -0,0 +1,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')
+
+