Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    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+
    there is some issues with mypy and inheritance iirc but I haven't looked into it for quite a while
    Dario
    @91DarioDev

    hello, i was trying to figure out how the config files should be done in hypercorn, but i found 0 examples unfortunately. as far i as i got reading the documentation i have to insert the parameters in config.py as global variables. anyways hypercorn is ignoring those variables

    i post the example file i wrote

    import asyncio
    from quart import Quart
    from hypercorn.asyncio import serve
    
    from hypercorn.config import Config
    
    
    app = Quart(__name__)
    
    @app.route('/')
    async def hello():
        return 'hello'
    
    if __name__ == '__main__':
        config = Config()
        config.from_pyfile("config.py")
        asyncio.run(serve(app, config))

    this is my config.py

    bind = '0.0.0.0:3068'

    anyways issuing python3.7 main.py it starts it [INFO] Running on http://127.0.0.1:8000

    i think the config.py should not be written this way if getting ignored.
    can someone give me a hint? thank you and sorry to bother you

    Dario
    @91DarioDev
    ok i solved in a different way using from_mapping :)
    Phil Jones
    @pgjones
    Ah, It should be config = Config.from_pyfile("config.py")
    As from_pyfile returns a config instance
    pgjones/hypercorn#178 (I welcome a MR)
    Dario
    @91DarioDev

    running hypercorn on production i get this error that i don't get in development

    Traceback (most recent call last):
      File "/home/chatincognitobot/.local/lib/python3.7/site-packages/quart/app.py", line 1862, in handle_request
        return await self.full_dispatch_request(request_context)
      File "/home/chatincognitobot/.local/lib/python3.7/site-packages/quart/app.py", line 1887, in full_dispatch_request
        result = await self.handle_user_exception(error)
      File "/home/chatincognitobot/.local/lib/python3.7/site-packages/quart/app.py", line 1100, in handle_user_exception
        return await self.handle_http_exception(error)
      File "/home/chatincognitobot/.local/lib/python3.7/site-packages/quart/app.py", line 1080, in handle_http_exception
        return await handler(error)
      File "/home/chatincognitobot/bot/web_server.py", line 64, in page_not_found_handler
        return await web_server_code.pages.page_not_found_handler(request, e)
      File "/home/chatincognitobot/bot/web_server_code/pages.py", line 29, in page_not_found_handler
        page_not_found=await web_server_code.locale.get_string('page_not_found', browser_language)
      File "/home/chatincognitobot/.local/lib/python3.7/site-packages/quart/templating.py", line 90, in render_template
        template = current_app.jinja_env.get_or_select_template(template_name_or_list)
      File "/home/chatincognitobot/.local/lib/python3.7/site-packages/quart/local.py", line 118, in getattr
        return getattr(self._get_current_object(), name)
      File "/home/chatincognitobot/.local/lib/python3.7/site-packages/quart/app.py", line 337, in jinja_env
        self._jinja_env = self.create_jinja_environment()
      File "/home/chatincognitobot/.local/lib/python3.7/site-packages/quart/app.py", line 429, in create_jinja_environment
        jinja_env = self.jinja_environment(self, **options)
      File "/home/chatincognitobot/.local/lib/python3.7/site-packages/quart/templating.py", line 32, in init
        super().__init__(**options)
    TypeError: __init__() got an unexpected keyword argument 'enable_async'

    i think it should be something related to async but i don't get waht

    1 reply
    Dario
    @91DarioDev
    more details: i have both python3 (old version) and python3.7 and i'm calling the script with python3.7 main.py
    McSinyx
    @McSinyx:matrix.org
    [m]
    which version of hypercorn and quart are you using?
    Dario
    @91DarioDev

    Name: Hypercorn
    Version: 0.11.2

    Name: Quart
    Version: 0.14.1

    Dario
    @91DarioDev
    the problem is just jinja because calling an endpoint not using templates it works perfectly.
    Dario
    @91DarioDev
    ok finally I got it working updating jinja2 with python3.7 -m pip install -U jinja2
    Augusto Zanellato
    @augustozanellato
    Have anybody tried to integrate certbot and hypercorn?
    I'm working on dockerizing a project which uses quart and hypercorn
    McSinyx
    @McSinyx:matrix.org
    [m]
    what do you mean by integrating
    Augusto Zanellato
    @augustozanellato
    Setting up certbot in such a way that it "restarts" or reloads hypercorn after cert renewal (if such a thing is needed)
    McSinyx
    @McSinyx:matrix.org
    [m]
    i think you can use systemd for hypercorn and use systemctl for such task