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'
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
from_pyfilereturns a config instance
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
make_test_body_with_headers(I get a non-empty body),
await request.filesreturns an empty dict inside my webapp code. I think this is related with the multipart header value not containing the boundary?
I've written about how to use postgres with Quart, specifying my preferred libraries (Databases & asyncpg) and how to convert types automatically,
Would be good to know if you think this is better as an extension
Hi @pgjones I am stumped with the following. I'm trying to pass a
cursor_id to a websocket view, like so:
@home_app.websocket("/ws") @login_required async def ws(): dbc = current_app.dbc cursor_id = int(request.args.get("cursor_id"))
But when I try to read the argument I get the error: "Attempt to access request outside of a relevant context". How can I pass that value from the template to the websocket endpoint?
FileStorage.streamnot being an asyncio object, or would we be locked waiting for the (currently) 16KB chunks of data on every iteration? I think those would probably be fine considering the kernel can cache possible future file reads, but I'm not sure.