Ejemplo n.º 1
0
Archivo: main.py Proyecto: KsAmJ/FQM
def create_app(config={}):
    ''' Create the flask app and setup extensions and blueprints.

    Returns
    -------
        app: Flask app
            app with settings and blueprints loadeds.
    '''
    app = Flask(__name__,
                static_folder=absolute_path('static'),
                template_folder=absolute_path('templates'))
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    app.config[
        'SQLALCHEMY_DATABASE_URI'] = f'sqlite:///{absolute_path(DATABASE_FILE)}?check_same_thread=False'
    app.config['DB_NAME'] = DATABASE_FILE
    # Autoreload if templates change
    app.config['TEMPLATES_AUTO_RELOAD'] = True
    # flask_upload settings
    # app.config['MAX_CONTENT_LENGTH'] = 500 * 1024 * 1024 # Remove Upload limit. FIX ISSUE
    app.config['UPLOADED_FILES_DEST'] = absolute_path('static/multimedia')
    app.config['UPLOADED_FILES_ALLOW'] = reduce(lambda sum, group: sum + group,
                                                SUPPORTED_MEDIA_FILES)
    app.config['SECRET_KEY'] = os.urandom(24)
    app.config.update(config)

    # Initiating extensions before registering blueprints
    Moment(app)
    QRcode(app)
    configure_uploads(app, files)
    login_manager.init_app(app)
    db.init_app(app)
    migrate.init_app(app, db=db)
    datepicker(
        app, local=['static/css/jquery-ui.min.css', 'static/jquery-ui.min.js'])
    colorpicker(app,
                local=['static/css/spectrum.css', 'static/spectrum.min.js'])
    fontpicker(app,
               local=[
                   'static/jquery-ui.min.js', 'static/css/jquery-ui.min.css',
                   'static/webfont.min.js', 'static/webfont.select.min.js',
                   'static/css/webfont.select.css'
               ])
    minify(app,
           js=True,
           cssless=True,
           caching_limit=3,
           fail_safe=True,
           bypass=['.min.*'])
    gTTs.init_app(app)
    gtranslator.init_app(app)

    # Register blueprints
    app.register_blueprint(administrate)
    app.register_blueprint(core)
    app.register_blueprint(cust_app)
    app.register_blueprint(manage_app)
    app.jinja_env.add_extension('jinja2.ext.loopcontrols')

    return app
Ejemplo n.º 2
0
def create_app():
    app = Flask(__name__,
                static_folder=r_path('static'),
                template_folder=r_path('templates'))
    if getattr(sys, 'frozen', False):
        basedir = os.path.dirname(sys.executable)
    else:
        basedir = os.path.abspath(os.path.dirname(__file__))
    # bootstrap = Bootstrap(app)
    pagedown = PageDown(app)
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + r_path(
        'data.sqlite')
    # Autoreload if templates change
    app.config['TEMPLATES_AUTO_RELOAD'] = True
    # flask_upload settings
    # app.config['MAX_CONTENT_LENGTH'] = 500 * 1024 * 1024 # Remove Upload limit. FIX ISSUE
    app.config['UPLOADED_FILES_DEST'] = r_path('static/multimedia')
    app.config['UPLOADED_FILES_ALLOW'] = mdal
    app.config['SECRET_KEY'] = os.urandom(24)
    # Intiating extensions before registering blueprints
    moment = Moment(app)
    qrc = QRcode(app)
    configure_uploads(app, files)
    login_manager.init_app(app)
    db.init_app(app)
    datepicker(
        app, local=['static/css/jquery-ui.min.css', 'static/jquery-ui.min.js'])
    colorpicker(app, local=['static/css/spectrum.css', 'static/spectrum.js'])
    fontpicker(app,
               local=[
                   'static/jquery-ui.min.js', 'static/css/jquery-ui.min.css',
                   'static/webfont.js', 'static/webfont.select.js',
                   'static/css/webfont.select.css'
               ])
    lessc(app)
    minify(app,
           js=True,
           cache=True,
           fail_safe=True,
           bypass=['/touch/<int:a>', '/serial/<int:t_id>', '/display'])
    gtts(app=app, route=True)
    gtranslator.init_app(app)
    # Register blueprints
    app.register_blueprint(administrate)
    app.register_blueprint(core)
    app.register_blueprint(cust_app)
    app.register_blueprint(errorsh_app)
    app.register_blueprint(manage_app)
    app.jinja_env.add_extension('jinja2.ext.loopcontrols')
    return app
Ejemplo n.º 3
0
def create_app(config_class=Config):
    app = Flask(__name__)
    CSRFProtect(app)
    app.config.from_object(Config)

    db.init_app(app)
    Migrate(app, db)
    Bootstrap(app)
    colorpicker(app)

    from trackyr.main.routes import main
    from trackyr.sources.routes import sources
    from trackyr.notification_agents.routes import notification_agents
    from trackyr.tasks.routes import tasks
    from trackyr.trackyr_config.routes import trackyr_config
    from trackyr.errors.handlers import errors

    app.register_blueprint(main)
    app.register_blueprint(sources)
    app.register_blueprint(notification_agents)
    app.register_blueprint(tasks)
    app.register_blueprint(trackyr_config)
    app.register_blueprint(errors)
    return app
Ejemplo n.º 4
0
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField, DecimalField, IntegerField, RadioField
from wtforms.validators import DataRequired, Length, NumberRange
from PIL import Image, ImageFont, ImageDraw
from io import BytesIO
import base64

from label_pil import suggar_num_to_str_en, generate_label

from wine_classifier_load import prediction

app = Flask(__name__)
app.config['SECRET_KEY'] = 'hard to guess string'
bootstrap = Bootstrap(app)
colorpicker(app)

app.debug = True
# toolbar = DebugToolbarExtension(app)


class LabelForm(FlaskForm):
    title1 = StringField('Enter title',
                         default="Dragon balls",
                         validators=[DataRequired(),
                                     Length(max=25)])
    title2 = StringField('Enter type',
                         default="Grape wine",
                         validators=[DataRequired(),
                                     Length(max=25)])
    number_alcohol = DecimalField(
Ejemplo n.º 5
0
rec.start()


##################
### Blueprints ###
#################@

app.register_blueprint(main)
app.register_blueprint(control, url_prefix="/control")
app.register_blueprint(project, url_prefix="/project")
app.register_blueprint(parameters, url_prefix="/parameters")



###################
### Colorpicker ###
###################

colorpicker(app, local=['static/spectrum.js', 'static/spectrum.css'])






	
if __name__ == "__main__":
    app.run(host='0.0.0.0', debug=True)