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

    Statics.g_app = fl.Flask('apps', static_url_path='')
    Statics.g_app.config['BUNDLE_ERRORS'] = True

    Statics.g_csrf = flwc.CSRFProtect()
    Statics.g_csrf.init_app(Statics.g_app)

    Statics.g_cors = flc.CORS(
        Statics.g_app, 
        resources={
            r'/*': {
                'origins': '*', 
                'send_wildcard': 'False'
            }
        })

    Statics.g_api = flr.Api(
        app=Statics.g_app,
        catch_all_404s=True)

    configure_api_resources()
    configure_app_templates()

    @Statics.g_app.route('/static/<path:path>')
    def send_static(path):
        return fl.send_from_directory('static', path)
Пример #2
0
def configure_api():

    Statics.g_app = fl.Flask('apps')
    Statics.g_app.config['BUNDLE_ERRORS'] = True

    Statics.g_csrf = flwc.CSRFProtect()
    Statics.g_csrf.init_app(Statics.g_app)

    Statics.g_cors = flc.CORS(
        Statics.g_app,
        resources={r'/*': {
            'origins': '*',
            'send_wildcard': 'False'
        }})

    Statics.g_api = flr.Api(app=Statics.g_app, catch_all_404s=True)

    Statics.g_api.add_resource(Info, '/info', endpoint='info')

    for _, model in Statics.g_models.items():

        url = '/api/{0}'.format(model['id'])
        endpoint = '{0}'.format(model['id'])

        Statics.g_api.add_resource(
            Hosting,
            url,
            endpoint=endpoint,
            resource_class_kwargs={'model_id': model['id']})

        print('Serving model "{0}" from "{1}"'.format(model['id'], url))
Пример #3
0
def create_app():
    monkey.patch_all()
    app = Flask(__name__)
    app.config.from_object('app.config.Develop')
    db.init_app(app)
    csrf.CSRFProtect(app)

    return app
Пример #4
0
#!/usr/bin/env python

from flask import render_template, redirect, request, Flask, url_for, abort, send_from_directory
from flask_wtf import FlaskForm, csrf
from wtforms import StringField, FieldList, FormField, SubmitField, IntegerField, FloatField, validators, BooleanField
import yaml, sys, binascii, os
from server_scripts import Parse, misc

# --------------------- CONFIGURATIONS -------------------------------------------------------------------------------------------------------
APP = Flask(__name__)
CSRF = csrf.CSRFProtect()
CSRF.init_app(APP)
APP.config['SECRET_KEY'] = os.urandom(32)
APP.config['UPLOAD_FOLDER'] = 'data'

with open("server_config.yaml", 'r') as stream:
    try:
        config = yaml.safe_load(stream)
    except yaml.YAMLError as exc:
        print(exc)
        sys.exit()

# global variables for holding data (temporarily)
global nPop, nPlant, lifeSpan
global populations, plants, tech_form, techs, params  # techs has class TechnologiesForm and has the input data
# tech_form is the form to be rendered to web interface


@APP.route('/', methods=['GET'])
def index():
    return (render_template('index.html'))
Пример #5
0
from forms import GombFeltoltesForm, GombKeresoForm, FelmeresKeresoForm, FelmeresFeltoltesForm, \
    LoginForm, PontlistaFeltoltesForm, PiacFeltoltesForm, KronikaFeltoltesForm
import lemu_gombfeltoltes
import lemu_gomblistazo
import lemu_gombkereso
import lemu_felmeres
import lemu_pontlista
import lemu_pontlista_feltoltes
import lemu_piac
import lemu_kronika
from user import user_validation
from eventlog import log_event, log_error

app = Flask(__name__)
csrf = csrf.CSRFProtect(app)

DEBUG = True

app.debug = True
app.config['SECRET_KEY'] = 'you-will-never-guess'


@app.route('/')
def root_page():
    if 'logged_in' not in session or not session['logged_in']:
        # Not logined, so redirect to the login page
        return redirect('/login')
    return render_template('index.html', title='Home page')

Пример #6
0
#!/usr/bin/python3
'''qbootstraper main application
'''

from flask import Flask
from flask_wtf import csrf

app = Flask(__name__)
csrf.CSRFProtect().init_app(app)  # enable CSRF protection

from qbflask.views import *


app.config.update(dict(
    DATABASE='qbflask.db',
    DEBUG=True,
    SECRET_KEY='secret',
    USERNAME='******',
    PASSWORD='******'
))

if __name__ == '__main__':
    app.run()