Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    paulinechane
    @PaulineChane

    It is the usage of the shutdown_trigger that I think is the issue for you. This is set by default to be a signal (Ctrl-C), but as noted this is only works if Quart is run on the main thread. Instead you can specify your own shutdown_trigger and use the run_task method. The shutdown_trigger should be an awaitable that is done when you want the app to shutdown.

    Thanks!

    hello! apologies for poorly phrased questions in advance, i am very new to python frameworks and asyncio!

    i am still having a hard time to get this to work -- trying to run a quart app to be used on a website along with bot that runs 24/7 on discord. my understanding is that this run_task() method would be run for the quart app?

    Baran Yildirim
    @baranyildirim
    Is it possible to make Quart work with React via templates? I would like to have a quart application where I use React components, but I do not want a single page application. I also don't want to run node and quart simultaneously.
    Phil Jones
    @pgjones
    Yes, you can just embed React as you need into the templates (via a script tag).
    I typically build a SPA and serve that with Quart
    Ernesto Ruge
    @the-infinity
    I usually use React + Quart or Fask partly jinja2-rendered, partly React-rendered. It works really fine (but Quart / Flask has not much to do with the React part, it just feeds it via API).
    It even works as a single page application including deeplinks and React Router if you set your endpoints in a correct way
    Phil Jones
    @pgjones
    @PaulineChane I'll try and write something up for this soon - short of time.
    Yes though, the run_task method would run the quart app.
    TheHolyRoger
    @TheHolyRoger
    hey @pgjones do you have plans to add "call_on_close" similar to flask to quart?
    Currently I'm using middleware around the asgi app, but it would be nice to have access to request variables within my called functions
    right now i'm manually parsing scope['query_string'] and the headers etc again myself
    Phil Jones
    @pgjones
    Could you spawn a background task for this?
    Do you need to guarantee the task doesn't start till the response has completed?
    TheHolyRoger
    @TheHolyRoger
    yeah because I don't want the response to remain open until the tasks have completed
    it's working as I want it to with middleware at the moment, I just thought it would be nice to have that flask functionality
    i was reading the quart source and wrapping the asgi app seems to be the only "hook" to execute functions after the request has closed
    Phil Jones
    @pgjones
    It is the only guaranteed way.
    Please could you open an issue for this - although I'll likely only add if Flask also adopts it, or it is clearly an async only feature
    TheHolyRoger
    @TheHolyRoger
    since flask uses Werkzeug request/response objects
    but thanks, will stick an issue on github later
    McSinyx
    @McSinyx:matrix.org
    [m]
    hi, why aren't templates observed for reloading by hypercorn?
    Phil Jones
    @pgjones
    Only knows about python files - however Quart in debug mode should observe and reload.
    See this
    McSinyx
    @McSinyx:matrix.org
    [m]
    thanks!
    András Mózes
    @mozesa
    Hello! @pgjones I created an pgjones/quart#118. Should I recreate it on GitLab? Thanks your help in advance.
    KAMAH_DANIEL_SOMTOCHUKWU
    @KDS-LIMITLESS
    Question: How do i process incoming request data in quart? in flask i could use request.get_json()....Is there any async library i could use for this?
    Phil Jones
    @pgjones
    await request.get_json()
    hypescript
    @hypescript
    Hello, I'm trying to run my Quart application with Flask_SQLAlchemy (and thus with flask_patch) inside a Docker container with uvicorn as ASGI server and I'm getting the RuntimeError: Flask Patching only works with the default event loop policy.
    In hindsight, I should've probably started with hypercorn-based Docker, but I couldn't find anything readily available at the time.
    Can you please either advise on how to make it work with uvicorn or recommend a hypercorn-based Docker image that can run quart?
    Phil Jones
    @pgjones
    You will need to disable uvloop with Uvicorn for this to work, --loop asyncio
    András Mózes
    @mozesa
    Hello! Is it possible to extract the different IP addresses of different adapters? I mean when I set hypercorn to serve my site on 0.0.0.0 it means that on localhost it will 127.0.0.1 on wireless it will 10.42.1.12 and etc. So is it possible to know all? Thanks in advance!
    1 reply
    Phil Jones
    @pgjones
    I've released Quart-Schema, 0.6.0. The headline feature is easier automated testing, as I explain in this article, https://pgjones.dev/blog/automatic-api-testing-2021/
    Phil Jones
    @pgjones
    ... and now Quart-Schema 0.7.0 which allows the JSON to be camelCased with the dataclass/models snake_cased (conversion is taken care of by Quart-Schema)
    luna
    @lun-4
    On quart-schema, is it possible to get the pydantic ValidationError that raised the RequestSchemaValidationError? On my API, I'm thinking of showing which fields did the API user fail to provide or provided incorrectly on a 400, but the given RequestSchemaValidationError does not have any other context
    Phil Jones
    @pgjones
    That is a good idea, could you open an issue?
    luna
    @lun-4
    Got it!
    Dario
    @91DarioDev
    Hello, congratulations for this good project. I had some doubts despite I read quart documentation several times. request isn’t passed to the handler but accessed globally. I had
    *reading the documentation I have understood that despite it is global, it’s global only inside the executed handler. So in case I have 2 endpoint handlers running concurrently, they both will have their global request, and I won’t have any problem that accessing request from endpoint handler A, I am reading the request of handler B because race conditions?
    Dario
    @91DarioDev
    since it’s globally I’m scared that accessing request from an handler I could access the request of another concurrent user and reply to the first user with the data of the second user. but I from the context doc page that it shouldn’t happen, but I would like to be sure I understood right
    Phil Jones
    @pgjones
    You do understand this right. Each request is handled in a separate asyncio Task, which means we can isolate the request information to that task using a ContextVar. Here is a test to ensure this works
    Dario
    @91DarioDev
    thank you very much for your kind reply! This library sounds really cool :)
    McSinyx
    @McSinyx:matrix.org
    [m]
    hi all, we've just released an alpha of a collaboration platform for students and supervisors, built on quart-trio
    a test deployment is running on hypercorn, which can be found at https://acanban.ga/p (all ipsum projects' users have their passwords spells backward, e.g. oliviak:kaivilo)
    the software is under AGPLv3+, available at https://github.com/Huy-Ngo/acanban
    we would like to take this chance and thank @pgjones for the support we've received in the last few months as well
    Phil Jones
    @pgjones
    Really nice. For reference I think you could add a few secure headers to your html routes e.g. these and a CSP. You may also want to add Quart-Rate-Limiter before some inconsiderate scraper pops by.
    It is cool to set it responding over HTTP/2. HTTP/3 is almost standardised now - chrome already switched to it - so that may be fun to try at some point.
    Also what is quart-trio-twice?
    McSinyx
    @McSinyx:matrix.org
    [m]
    thanks, these headers and rate limiter seems to be great to have
    i don't think we use and http/2 feature though, it's just hypercorn default I guess
    quart-trio-twice is a temporary fork of quart-trio 0.6 (3 times 2 is 6) with some patches added: we haven't found the time to migrate to quart 0.14+ / quart-trio 0.7+