Beispiel #1
0
def test_create_route_order_incr():
    "tests route order when routes are added incrementally"
    routes = [('/api/<api_path+>', api, render_basic),
              ('/<one>/<two>', two_segments, render_basic),
              ('/<one>/<two>/<three>', three_segments, render_basic)]
    app = Application()
    client = app.get_local_client()
    for r in routes:
        app.add(r)
        assert client.get('/api/a').data == b'api: a'
        assert client.get('/api/a/b/').data == b'api: a/b'
    return
Beispiel #2
0
def test_create_route_order_incr():
    "tests route order when routes are added incrementally"
    routes = [('/api/<path:api_path>', api, render_basic),
              ('/<one>/<two>', two_segments, render_basic),
              ('/<one>/<two>/<three>', three_segments, render_basic)]
    app = Application()
    client = Client(app, BaseResponse)
    for r in routes:
        app.add(r)
        yield eq_, client.get('/api/a/b').data, 'api: a/b'
        yield eq_, app.wmap._rules[-1].rule, r[0]
    return
Beispiel #3
0
def test_create_route_order_incr():
    "tests route order when routes are added incrementally"
    routes = [('/api/<api_path+>', api, render_basic),
              ('/<one>/<two>', two_segments, render_basic),
              ('/<one>/<two>/<three>', three_segments, render_basic)]
    app = Application()
    client = app.get_local_client()
    for r in routes:
        app.add(r)
        assert client.get('/api/a/b').data == b'api: a/b'
        assert app.routes[-1].get_info()['url_pattern'] == r[0]
    return
Beispiel #4
0
def main():
    prs = argparse.ArgumentParser()
    prs.add_argument("--debug", action="store_true")
    opts, _ = prs.parse_known_args()
    debug = opts.debug

    v1_app = create_v1_app()
    app = Application([("/v1", v1_app)])
    meta_app = MetaApplication()
    if debug:
        app.add(("/", meta_app))

    app.serve(port=PORT, threaded=True)

    return
Beispiel #5
0
def main():
    prs = argparse.ArgumentParser()
    prs.add_argument('--debug', action='store_true')
    opts, _ = prs.parse_known_args()
    debug = opts.debug

    v1_app = create_v1_app()
    app = Application([('/v1', v1_app)])
    meta_app = MetaApplication()
    if debug:
        app.add(('/', meta_app))
        app.serve(port=PORT)
    else:
        group = Group(wsgi_apps=[(app, ('0.0.0.0', PORT), False),
                                 (meta_app, ('0.0.0.0', META_PORT), False)],
                      num_workers=1,
                      prefork=True,
                      daemonize=True)
        group.serve_forever()