Пример #1
0
def do_setup():
    """

    :return:
    """

    #todo: setup
    """
    if bottle.request.method == 'GET':
        return bottle.template('setup')
    else:
        prms = bottle.request.POST

        aconfig = configparser.ConfigParser()
        aconfig['system'] = {
            'login_required': prms.get('login_required', default = 0),
        }
        with open('%s/config.ini' % appconf.basepath, 'w+', encoding='utf-8') as f:
            aconfig.write(f)

        bottle.redirect('/setup_ok')
    """

    aconfig = configparser.ConfigParser()
    aconfig['system'] = {
        'login_required': 0,
    }
    with open('%s/config.ini' % appconf.basepath, 'w+', encoding='utf-8') as f:
        aconfig.write(f)
    from app import index
    init_app()
    baseApp.route('/', method=['GET', 'POST'], callback=index)
    return index()
Пример #2
0
def setup_ok():
    from app import index

    init_app()

    baseApp.route('/', method=['GET', 'POST'], callback=index)
    return bottle.template('setup_ok')
Пример #3
0
def run_app(do_debug=True):
    if hasattr(sys, 'frozen'):
        appconf.basepath = os.path.dirname(os.path.abspath(sys.argv[0]))
    else:
        appconf.basepath = os.path.abspath(os.path.dirname(__file__))

    if not(os.path.exists(appconf.basepath + '/config.ini')):
        baseApp.route('/', method=['GET', 'POST'], callback=firstrun.do_setup)
        baseApp.route('/setup_ok', method=['GET', 'POST'], callback=firstrun.setup_ok)
    else:
        init_app()
        baseApp.route('/', method=['GET', 'POST'], callback=index)

    #template defaults
    BaseTemplate.defaults['appconf'] = appconf
    BaseTemplate.defaults['highlight_sql'] = highlight_sql
    BaseTemplate.defaults['get_rdb_type'] = get_rdb_type

    return SessionMiddleware(baseApp, {'session.type': 'file',
                                       'session.cookie_expires': 18000,
                                       'session.data_dir': appconf.basepath + '/sessions',
                                       'session.auto': True})
Пример #4
0
from flask import Flask, render_template, request
from api import api
from admin import admin
from db import db, Sport
import storage
import common
import betcalc

app = Flask(__name__)
app.config.from_pyfile("betcalc.conf")

db.init_app(app)
admin.init_app(app)
common.init_app(app)
# init storage
storage.init_storage(app)

app.register_blueprint(api)


@app.route('/')
def index():
    sports = Sport.query.all()
    return render_template('index.html', context='home', sports=sports)


@app.route('/<int:id>')
def sport(id):
    models = storage.get_models_meta().values()
    sport = Sport.query.get(id)
    return render_template('index.html',