Exemplo n.º 1
0
def mk_frontend(config):
    dsn = config['pcds_dsn']
    pcds_config = {
        'title':
        'BC Station Data - PCDS',
        'js_files':
        wrap_mini([
            'js/crmp_map.js', 'js/crmp_controls.js', 'js/crmp_download.js',
            'js/crmp_filters.js', 'js/crmp_app.js'
        ],
                  basename=url_base,
                  debug=(not config['js_min']))
    }

    def session_scope_factory():
        return session_scope(dsn)

    count_stations_app = CountStationsApp(session_scope_factory)
    record_length_app = CountRecordLengthApp(session_scope_factory,
                                             max_stns=100)
    legend_app = LegendApp(dsn)

    pcds_map_config = updateConfig(config, pcds_config)
    map_app = MapApp(**pcds_map_config)

    return DispatcherMiddleware(
        map_app, {
            '/map': map_app,
            '/record_length': record_length_app,
            '/count_stations': count_stations_app,
            '/images/legend': legend_app
        })
Exemplo n.º 2
0
def mk_backend(config):
    dsn = config['pcds_dsn']
    dispatch_app = PcdsDispatcher(
        templates=resource_filename('pdp_util', 'templates'),
        ol_path=None,  # global_config['ol_path'],
        app_root=config['app_root'],
        conn_params=dsn)

    zip_app = PcdsZipApp(dsn)

    app = DispatcherMiddleware(zip_app, {
        '/lister': dispatch_app,
        '/agg': zip_app
    })
    return app
Exemplo n.º 3
0
def mk_frontend(config):
    hydro_stn_config = {
        'title':
        'Modelled Streamflow Data',
        'js_files':
        wrap_mini([
            'js/jquery.csv-0.71.js', 'js/hydro_stn_download.js',
            'js/hydro_stn_map.js', 'js/hydro_stn_controls.js',
            'js/hydro_stn_app.js'
        ],
                  basename=url_base,
                  debug=(not config['js_min']))
    }

    config = updateConfig(config, hydro_stn_config)
    map_app = MapApp(**config)

    return DispatcherMiddleware(map_app, {'/map': map_app})
Exemplo n.º 4
0
def make_raster_frontend(config,
                         ensemble_name,
                         url_base,
                         title,
                         ensemble_lister_class,
                         js_files,
                         css_files=[]):
    dsn = config['dsn']
    portal_config = {
        'title':
        title,
        'ensemble_name':
        ensemble_name,
        'css_files':
        css_files,
        'js_files':
        wrap_mini(js_files, basename=url_base, debug=(not config['js_min']))
    }

    portal_config = updateConfig(config, portal_config)
    map_app = MapApp(**portal_config)

    conf = raster_conf(dsn, config, ensemble_name, url_base)
    catalog_server = RasterCatalog(dsn, conf)

    menu = ensemble_lister_class(dsn)

    metadata = RasterMetadata(dsn)

    return DispatcherMiddleware(
        map_app, {
            '/map': map_app,
            '/catalog': catalog_server,
            '/menu.json': menu,
            '/metadata.json': metadata
        })
Exemplo n.º 5
0
from flask import Flask
from werkzeug import DispatcherMiddleware
 
app1 = Flask(__name__)
app2 = Flask(__name__)
app = Flask(__name__)
 
@app1.route('/')
def index():
    return "This is app1!"
 
@app2.route('/')
def index():
    return "This is app2!"
 
@app.route('/')
def index():
    return "This is app!"
 
app = DispatcherMiddleware(app, {
            '/app1':        app1,
            '/app2':        app2
        })
 
if __name__ == '__main__':
    from werkzeug.serving import run_simple
    run_simple('192.168.1.99',5000, app)
Exemplo n.º 6
0
def make_app():
    return DispatcherMiddleware(redirect_to_pycwb, {
            '/pycwb': application})
Exemplo n.º 7
0
def prefix_application_path(app, prefix):
    """ Add a prefix to all URLs. Need this typically for serving the whole application
    under a proxy """
    app.wsgi_app = DispatcherMiddleware(
        Flask('dummy_app'),  #for 404,
        {prefix: app.wsgi_app})