Beispiel #1
0
def setup_app():
    app = Flask(__name__)
    app.config.from_object('elevation.config')
    with open(environ["ORIENTEER_CONFIG"]) as f:
        cfg = load(f)
        cfg["SRID"] = cfg["srid"]
        cfg["SQLALCHEMY_DATABASE_URI"] = cfg.get("database_uri", None)

    app.config.update(cfg)
    global SRID
    SRID = app.config.get("srid")
    init_projection(app, db)
    try:
        db.init_app(app)
    except AttributeError:
        raise Exception(
            "Please specify a database uri in the ORIENTEER_CONFIG json file")

    __setup_endpoints(app, db)
    log.info("App setup complete")

    def within_context(func):
        @wraps(func)
        def wrapper(*args, **kwargs):
            with app.app_context():
                return func(*args, **kwargs)

        return wrapper

    app.context = within_context

    return app
Beispiel #2
0
def create_app(context):
    app = Flask(
        __name__,
        static_folder='static',
        template_folder='templates'
    )
    init_blueprints(app, blueprints)
    app.context = context
    return app
Beispiel #3
0
def create_app(name=__name__, **kwargs):

    # create app and load configuration variables
    app = Flask(name, instance_relative_config=False)
    app.config.from_object(Config)
    app.context = Context

    # initialize logging
    init_logging(**kwargs)

    # configure headers
    CORS(app)

    with app.app_context():
        # configure database
        app.db = db
        db.init_app(app)
        migrate.init_app(app, db)

        # configure imports
        init_models(app)
        init_schemas(app)

        # configure celery
        app.redis = redis_db
        init_celery(app, celery)
        load_tasks()

        # configure views
        compress.init_app(app)
        init_views(app)

    # configure developer tools
    Context.register(app, db, celery)
    Cli.register(app, db, celery)

    return app
Beispiel #4
0
#!/usr/local/bin/python
from flask import Flask
from .utils.application_context import ApplicationContext


app = Flask(__name__)
app.context = ApplicationContext(app)
Beispiel #5
0
import math
import json
import random
import werkzeug.serving



gevent.monkey.patch_all()


from flask import Flask, request, Response, render_template


app = Flask(__name__)
app.debug = True
app.context = zmq.Context(1)

DIRECCION_ENTRADA = 'tcp://127.0.0.1:5555'
DIRECCION_SALIDA = 'inproc://queue'


@app.route('/')
def index():
    '''Página principal desde donde se accede al resto de las páginas'''
    return render_template('index.html')

def retransmisor(dir_entrada=DIRECCION_ENTRADA,
                 dir_salida=DIRECCION_SALIDA):
    '''Utiliza un dipositivo forwareder para retransmitir mensajes
    desde un extremo subscriptor, hacia una extremo emisor. Pueden
    existir múltiples emisores y múltiples receptores conectados
Beispiel #6
0
from flask import Flask, render_template, Response
import zmq
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure
import StringIO
import matplotlib.pyplot as plt

app = Flask(__name__)
app.context = zmq.Context()
port = '5555'


def doublePlotter(fig, ax, timeData, xData, yData):
    ax[0].plot(timeData, xData, color='r', linewidth=2)
    ax[1].plot(timeData, yData, color='b', linewidth=2)
    ax[0].set_ylabel('coeff1')
    ax[1].set_ylabel('coeff2')
    ax[0].axhline(3.2, color='k', ls='dashed')
    ax[1].axhline(0.6, color='k', ls='dashed')
    canvas = FigureCanvas(fig)
    picOutput = StringIO.StringIO()
    canvas.print_png(picOutput)
    return picOutput.getvalue()


def generateImage():
    historyTime, historyCoeff1, historyCoeff2 = [], [], []
    fig, ax = plt.subplots(2, sharex=True)
    sock = app.context.socket(zmq.SUB)
    sock.connect("tcp://localhost:%s" % port)
    sock.setsockopt(zmq.SUBSCRIBE, '')
Beispiel #7
0
        session.commit()
        flash('Menu Item Successfully Edited')
        return redirect(url_for('showMenu', restaurant_id=restaurant_id))
    else:
        return render_template('editmenuitem.html',
                               restaurant_id=restaurant_id,
                               menu_id=menu_id,
                               item=editedItem)


#Delete a menu item
@app.route('/restaurant/<int:restaurant_id>/menu/<int:menu_id>/delete',
           methods=['GET', 'POST'])
def deleteMenuItem(restaurant_id, menu_id):
    restaurant = session.query(Restaurant).filter_by(id=restaurant_id).one()
    itemToDelete = session.query(MenuItem).filter_by(id=menu_id).one()
    if request.method == 'POST':
        session.delete(itemToDelete)
        session.commit()
        flash('Menu Item Successfully Deleted')
        return redirect(url_for('showMenu', restaurant_id=restaurant_id))
    else:
        return render_template('deleteMenuItem.html', item=itemToDelete)


if __name__ == '__main__':
    app.secret_key = 'super_secret_key'
    app.debug = True
    app.context = ('server.crt', 'server.key')
    app.run(host='0.0.0.0', port=5000, threaded=True)