__init__.py 1.46 KB
Newer Older
1
    # app/__init__.py
2

3
4
5
6
7
# local imports
from __future__ import print_function

import os
import sys
8
import subprocess
9
10
import time

11
# third-party imports
12
from flask import Flask, redirect, url_for, request, render_template, flash, session
13
from flask_wtf import FlaskForm
14
from flask_bootstrap import Bootstrap
15
16
from wtforms import StringField, SubmitField, TextAreaField, validators
from flask_socketio import SocketIO
17

18
# global declarations
19
20
21
22
23


def create_app(config_name):
    app = Flask(__name__) # initialization of the flask app
    Bootstrap(app) # allowing app to use bootstrap
24

25
26
    global return_url
    return_url = ''
27

28
29
30
    @app.route('/', methods=['GET', 'POST']) # initial route to display the reg page
    def index():
        global return_url
31
        username = "name_test"
32

33
        if "redir" in request.args and return_url == "": # check for redir arg in url
34
            return_url = request.args.get("redir") or "/pun/sys/dashboard"
35
            if name != "":
36

37
        return render_template('auth/SignUp.html', user=username)
38

39
    # misc page error catching
40
41
42
43
44
45
46
47
48
49
50
51
52
    @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