Newer
Older
Mitchell Moore
committed
# local imports
from __future__ import print_function
Mitchell Moore
committed
import vars
Mitchell Moore
committed
# third-party imports
Mitchell Moore
committed
import uuid
Mitchell Moore
committed
from flask import Flask, redirect, url_for, request, render_template, flash, session
Mitchell Moore
committed
from flask_bootstrap import Bootstrap
Mitchell Moore
committed
import random
Mitchell Moore
committed
def create_app(config_name):
app = Flask(__name__) # initialization of the flask app
Bootstrap(app) # allowing app to use bootstrap
Mitchell Moore
committed
Mitchell Moore
committed
@app.route('/', methods=['GET', 'POST']) # initial route to display the reg page
def index():
Mitchell Moore
committed
Mitchell Moore
committed
if 'uid' not in session:
session['uid']=str(uuid.uuid4())
if "redir" in request.args and 'return_url' not in session: # check for redir arg in url
Mitchell Moore
committed
session['return_url'] = request.args.get("redir")
elif "redir" not in request.args and 'return_url' not in session:
session['return_url'] = vars.default_referrer
else:
session['return_url'] = request.referrer
Mitchell Moore
committed
Mitchell Moore
committed
return render_template('auth/SignUp.html', room_id=session['uid'], referrer=session['return_url'])
Mitchell Moore
committed
# misc page error catching
@app.errorhandler(403)
def forbidden(error):
return render_template('errors/403.html', title='Forbidden'), 403
@app.errorhandler(404)
def page_not_found(error):
return render_template('errors/404.html', title='Page Not Found'), 404
@app.errorhandler(500)
def internal_server_error(error):
return render_template('errors/500.html', title='Server Error'), 500
return app