How to use the quart.url_for function in Quart

To help you get started, we’ve selected a few Quart examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pgjones / quart / examples / blog / blog.py View on Github external
async def create():
    if not session.get('logged_in'):
        abort(401)
    db = get_db()
    form = await request.form
    db.execute(
        "INSERT INTO post (title, text) VALUES (?, ?)",
        [form['title'], form['text']],
    )
    db.commit()
    await flash('New entry was successfully posted')
    return redirect(url_for('posts'))
github OutlierVentures / ANVIL / anvil / verifier.py View on Github external
async def setup():
    global verifier, pool_handle
    verifier, pool_handle = await common_setup('verifier')
    return redirect(url_for('index'))
github Flowminder / FlowKit / flowapi / flowapi / query_endpoints.py View on Github external
f"Received reply {reply}", request_id=request.request_id
    )

    if reply["status"] == "error":
        # TODO: currently the reply msg is empty; we should either pass on the message payload (which contains
        #       further information about the error) or add a non-empty human-readable error message.
        #       If we pass on the payload we should also deconstruct it to make it more human-readable
        #       because it will contain marshmallow validation errors (and/or any other possible errors?)
        return (
            {"status": "Error", "msg": reply["msg"], "payload": reply["payload"]},
            400,
        )
    elif reply["status"] == "success":
        assert "query_id" in reply["payload"]
        d = {
            "Location": url_for(
                f"query.poll_query", query_id=reply["payload"]["query_id"]
            )
        }
        return (
            dict(
                query_id=reply["payload"]["query_id"],
                progress=reply["payload"]["progress"],
            ),
            202,
            d,
        )
    else:
        return (
            {"status": "Error", "msg": f"Unexpected reply status: {reply['status']}",},
            500,
        )
github OutlierVentures / ANVIL / anvil / prover.py View on Github external
async def respond():
    global prover, anchor_ip, issuer_port, multiple_onboard
    port = issuer_port
    # have_verinym as condition here doesn't work - see scoping
    if 'did_info' in prover:
        multiple_onboard = True
         # If all running on same machine, set manually
        port = verifier_port
    prover, anchor_ip = await common_respond(prover, received_data, pool_handle, port)
    return redirect(url_for('index'))
github pgjones / quart / examples / flask_ext / flask_ext.py View on Github external
if request.method == 'GET':
        return '''
               <form method="POST">
                <input placeholder="username" id="username" name="username" type="text">
                <input placeholder="password" id="password" name="password" type="password">
                <input type="submit">
               </form>
               '''

    username = (await request.form)['username']
    password = (await request.form)['password']
    if username in users and compare_digest(password, users[username]['password']):
        user = User()
        user.id = username
        flask_login.login_user(user)
        return redirect(url_for('protected'))

    return 'Bad login'
github pgjones / quart / examples / http2_push / http2_push.py View on Github external
async def push():
    await make_push_promise(url_for('static', filename='style.css'))
    for i in range(app.max_tiles * app.max_tiles):
        await make_push_promise(url_for('tile', tile_number=i))
    return await render_template(
        'index.html', max_tiles=app.max_tiles, title='Using push promises',
    )
github pgjones / quart / examples / http2 / http2.py View on Github external
async def index():
    await make_push_promise(url_for('static', filename='http2.css'))
    await make_push_promise(url_for('static', filename='http2.js'))
    return await render_template('index.html')
github AceFire6 / ordered-arrowverse / ordering / views.py View on Github external
async def recent_episodes():
    feed = AtomFeed(
        title='Arrowverse.info - Recent Episodes',
        feed_url=request.url,
        url=request.url_root,
        logo=url_for('static', filename='favicon.png', _external=True),
        icon=url_for('static', filename='favicon.png', _external=True),
    )

    hide_shows_list = request.args.getlist('hide_show')

    newest_first_episode_list = get_full_series_episode_list(excluded_series=hide_shows_list)[::-1]

    for episode in newest_first_episode_list[:15]:
        title = '{series} - {episode_id} - {episode_name}'.format(**episode)
        content = '{series} {episode_id} {episode_name} will air on {air_date}'.format(**episode)
        show_dict = app.config['SHOW_DICT_WITH_NAMES'][episode['series']]
        data_source = f"{show_dict['root']}{show_dict['url']}"

        feed.add(
            title=title,
            content=content,
            content_type='text',
github Roxxers / roxbot / webapp / routes.py View on Github external
def wrapper(*args, **kwargs):
        if session.get('oauth2_token', None) is None:
            session['login_referrer'] = url_for(func.__name__)
            return redirect(url_for("login"))
        else:
            return func(*args, **kwargs)
    wrapper.__name__ = func.__name__  # Weird work around needed to decorate app routes
github Roxxers / roxbot / webapp / routes.py View on Github external
oauth_token = session.get('oauth2_token', None)
    if oauth_token:
        discord_session = oauth.make_session(token=oauth_token)
        logged_in_user = discord_session.get(webapp.API_BASE_URL + '/users/@me').json()
    else:
        discord_session = {}
        logged_in_user = {}

    return await render_template(
        "index.html",
        oauth_token=oauth_token,
        discord_session=discord_session,
        logged_in_user=logged_in_user,
        IMAGE_BASE_URL=webapp.IMAGE_BASE_URL,
        client=app.discord_client,
        invite_url=discord.utils.oauth_url(app.discord_client.user.id, permissions=discord.Permissions(1983245558), redirect_uri=url_for(".index"))
    )