Beispiel #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()
Beispiel #2
0
def setup_ok():
    from app import index

    init_app()

    baseApp.route('/', method=['GET', 'POST'], callback=index)
    return bottle.template('setup_ok')
Beispiel #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})