__init__.py 1.29 KB
Newer Older
nick's avatar
nick committed
1
2
3
# app/__init__.py

# local imports
Mitchell Moore's avatar
Mitchell Moore committed
4
5
6
from __future__ import print_function

# third-party imports
7
import uuid
Mitchell Moore's avatar
Mitchell Moore committed
8
9
from flask import Flask, redirect, url_for, request, render_template, flash, session
from flask_bootstrap import Bootstrap
10
import random
nick's avatar
nick committed
11
12
13
14
15
16


def create_app(config_name):

    app = Flask(__name__)

17
    @app.route('/', methods=['GET', 'POST']) # initial route to display the reg page
nick's avatar
nick committed
18
    def index():
19
        global return_url
20
21
22

        if 'username' not in session:
            session['username'] = "name_test" + str(random.randint(0, 10000))
23
24
25

        if 'uid' not in session:
            session['uid']=str(uuid.uuid4())
nick's avatar
nick committed
26

27
28
29
        if "redir" in request.args and return_url == "": # check for redir arg in url
            return_url = request.args.get("redir") or "/pun/sys/dashboard"

30
        return render_template('auth/SignUp.html', user=session['username'], room_id=session['uid'])
nick's avatar
nick committed
31
32
33
34
35
36
37
38
39
40
41
42
43
44

    @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