__init__.py 1016 Bytes
Newer Older
1
2
3
import os
from flask import Flask, redirect, url_for
from . import evalweb
4
from flaskext.markdown import Markdown
5
6
7
8


# taken from tutorial on flask.palletsprojects.com/en/1.1.x/tutorial

9
def create_app(test_config=None) -> Flask:
10
11
12
    # create and configure the app
    app = Flask(__name__, instance_relative_config=True)
    app.config.from_mapping(SECRET_KEY='dev')
13
    Markdown(app, extensions=['fenced_code'])
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

    if test_config is None:
        # load the instance config, if it exists, when not testing
        app.config.from_pyfile('config.py', silent=True)
    else:
        # load the test config if passed in
        app.config.from_mapping(test_config)

    # ensure the instance folder exists
    try:
        os.makedirs(app.instance_path)
    except OSError:
        pass

    @app.route('/')
Kateřina Sloupová's avatar
Kateřina Sloupová committed
29
    # initial page is compare mode
30
31
32
33
34
35
    def index():
        return redirect(url_for('eval.compare'))

    app.register_blueprint(evalweb.bp)
    app.add_url_rule('/compare', endpoint='index')

36
    return app