How to use the quart.request 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 / tests / test_blueprints.py View on Github external
async def test_blueprint_url_prefix() -> None:
    app = Quart(__name__)
    blueprint = Blueprint("blueprint", __name__)
    prefix = Blueprint("prefix", __name__, url_prefix="/prefix")

    @app.route("/page/")
    @blueprint.route("/page/")
    @prefix.route("/page/")
    async def route() -> ResponseReturnValue:
        return "OK"

    app.register_blueprint(blueprint, url_prefix="/blueprint")
    app.register_blueprint(prefix)

    async with app.test_request_context("/page/"):
        assert request.blueprint is None

    async with app.test_request_context("/prefix/page/"):
        assert request.blueprint == "prefix"

    async with app.test_request_context("/blueprint/page/"):
        assert request.blueprint == "blueprint"
github dnknth / ldap-ui / app.py View on Github external
async def unique( msgid: int) -> Tuple[str, Dict[str, List[bytes]]]:
    'Concurrently collect a unique result'
    res = None
    async for r in result( msgid):
        if res is None: res = r
        else:
            request.ldap.abandon( msgid)
            raise ValueError( "Expected unique result")
    if res is None: 
        raise ValueError( "Expected unique result")
    return res
github microsoft / BotBuilder-Samples / samples / python / wip / python_quart / 02.echo-bot / app.py View on Github external
async def messages():
    # Main bot message handler.
    if "application/json" in request.headers["Content-Type"]:
        body = await request.json
    else:
        return Response("", status=415)

    activity = Activity().deserialize(body)
    auth_header = (
        request.headers["Authorization"] if "Authorization" in request.headers else ""
    )

    try:
        await ADAPTER.process_activity(activity, auth_header, BOT.on_turn)
        return Response("", status=201)
    except Exception as exception:
        raise exception
github osks / httpkom / httpkom / misc.py View on Github external
def get_bool_arg_with_default(args, arg, default):
    if arg in request.args:
        if request.args[arg] == 'false':
            val = False
        elif request.args[arg] == 'true':
            val = True
        else:
            abort(400)
    else:
        val = default
    return val
github OutlierVentures / ANVIL / anvil / issuer.py View on Github external
async def data():
    global received_data, request_ip
    received_data = await request.data
    request_ip = request.remote_addr
    print(received_data)
    return '200'
github mikeyy / nonoCAPTCHA / examples / app_task.py View on Github external
async def create_task():
    while not proxies:
        await asyncio.sleep(1)

    pageurl = request.args.get("pageurl")
    sitekey = request.args.get("sitekey")
    if not pageurl or not sitekey:
        result = "Missing `sitekey` or `pageurl`"
    else:
        task_id = "".join(
            random.choice("23456789ABCDEFGHJKLMNPQRSTUVWXYZ") for x in range(8)
        )
        tasks.update({task_id: {"status": "processing"}})
        asyncio.ensure_future(work(pageurl, sitekey, task_id))
        result = json.dumps({"task_id": task_id})
    return Response(result, mimetype="text/json")
github OutlierVentures / ANVIL / anvil / prover.py View on Github external
async def proof_request():
    global prover, request_ip
    prover['authcrypted_proof_request'] = await request.data
    # Old request IP now has name anchor IP so can safely overwrite
    request_ip = request.remote_addr
    return '200'
github osks / httpkom / httpkom / misc.py View on Github external
def get_bool_arg_with_default(args, arg, default):
    if arg in request.args:
        if request.args[arg] == 'false':
            val = False
        elif request.args[arg] == 'true':
            val = True
        else:
            abort(400)
    else:
        val = default
    return val