Refactor the code into modules, it was getting unweildy.
This commit is contained in:
parent
2611d70185
commit
ee5ea51532
12 changed files with 73 additions and 70 deletions
30
endpoints/web.py
Normal file
30
endpoints/web.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
from flask import abort, send_file, redirect, request
|
||||
|
||||
from data import model
|
||||
from app import app
|
||||
|
||||
|
||||
@app.route('/', methods=['GET'])
|
||||
def index():
|
||||
return send_file('templates/index.html')
|
||||
|
||||
|
||||
@app.route('/signin', methods=['POST'])
|
||||
def signin():
|
||||
username = request.form['username']
|
||||
password = request.form['password']
|
||||
|
||||
#TODO Allow email login
|
||||
verified = model.verify_user(username, password)
|
||||
if verified:
|
||||
logger.debug('Successfully signed in as: %s' % username)
|
||||
|
||||
login_user(_LoginWrappedDBUser(verified))
|
||||
return redirect(request.args.get('next') or url_for('index'))
|
||||
|
||||
abort(403)
|
||||
|
||||
|
||||
@app.route('/signin', methods=['GET'])
|
||||
def render_signin_page():
|
||||
return send_file('templates/signin.html')
|
Reference in a new issue