from toiletbowlchamp.data_utils import *
from toiletbowlchamp.config import *
from flask import Flask, request, session, g, redirect, url_for, abort, render_template, flash
from flask_bootstrap3 import Bootstrap

app = Flask(__name__)
Bootstrap(app)


@app.route('/')
def index():
    return render_template("index.html")


@app.route('/', methods=['POST'])
def league_url_submission():
    url = request.form['leagueURL']
    try:
        id = leagueID_from_url(url)
        return redirect("/league/{0}".format(id))
    except:
        '''todo: handle case when URL is bad'''


@app.route('/league/<int:leagueid>', methods=['GET'])
def choose_owner(leagueid):
    owners = get_owners_from_url(leagueid)
    return render_template("owners.html", owners=owners, league=leagueid)


@app.route('/league/<int:leagueid>/<int:ownerid>', methods=['GET'])
Beispiel #2
0
from flask_bootstrap3 import Bootstrap
from flask_migrate import Migrate
import os

from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from flask_login import LoginManager, current_user, login_user, logout_user, login_required
from flask_wtf import CSRFProtect
from app.forms import RegistrationForm, LoginForm

app = Flask(__name__)
FLASK_ENV = os.environ.get("FLASK_ENV") or 'development'
app.config.from_object('app.config.%s%sConfig' %
                       (FLASK_ENV[0].upper(), FLASK_ENV[1:]))
app.static_folder = app.config['STATIC_FOLDER']
bootstrap = Bootstrap(app)
CSRFProtect(app)

db = SQLAlchemy(app)
migrate = Migrate(app, db)
login = LoginManager(app)

from app.models import User, Presentation, Room, Role, Author, Schedule


@login.user_loader
def load_user(id):
    return User.query.get(int(id))


admin = Admin(app=app, name='Admin', template_mode='bootstrap3')
Beispiel #3
0
def create_app():
    app = Flask(__name__)
    Bootstrap(app)

    return app
Beispiel #4
0
from flask import Flask
from flask_bootstrap3 import Bootstrap
from config import config_options

bootstrap = Bootstrap()


def create_app(config_name):

    app = Flask(__name__)

    # Creating the app configurations
    app.config.from_object(config_options[config_name])

    # Initializing flask extensions
    bootstrap.init_app(app)

    #Registering the blueprint
    from .main import main as main_blueprint
    app.register_blueprint(main_blueprint)

    #setting config
    from .requests import configure_request  #Importing configure_request function
    configure_request(app)  #Calling the function and passing the app instance

    # Will add the views and forms

    return app
Beispiel #5
0
from urllib.parse import urlparse
import os


import markdown
from markdown.inlinepatterns import LinkPattern, LINK_RE


from flask import Flask, render_template, Markup, request, url_for
from werkzeug.exceptions import NotFound
from flask_bootstrap3 import Bootstrap


app = Flask(__name__)

bootstrap = Bootstrap()
bootstrap.init_app(app)

APP_ROOT = os.path.dirname(os.path.abspath(__file__))
MARKDOWN_DIR = os.path.join(APP_ROOT, 'markdown_files')


def run_server():
    """Start application
    """
    app.run(port=8080, debug=True, threaded=True)


def shutdown_server():
    """Shutdown server
    """