-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flask Return action error logs to webserver #191
Comments
I guess the hardest thing I haven't worked out is how to get in the app log of the action instance |
I'm not certain but possibly some solutions here: https://stackoverflow.com/questions/66277372/writing-flask-console-logs-to-an-html-template-as-and-when-it-appears |
Haven't looked into this. It may grab all console logs. I think we want to get just the ones from app.logger (in particular the ones related to the last ran action) although maybe we can filter before we send it out 🤔 If we can get the logs into the form of a string array I can pass it. Just have to work out how. |
If I have some spare time I'll take a look at both of these issues I recently created. For now. I'll take a brake 👍 |
In its current status the response message to the action is a status code Ex:
emhass/src/emhass/web_server.py
Line 55 in 78309ad
This however doesn't indicate if there was an error during action (and if there was, what was it). This only gives us the information that the action has completed (with an 201 code)
PR #190 implements alert box element that currently only facilitates JSON input format error:
emhass/src/emhass/templates/index.html
Lines 200 to 203 in 78309ad
I believe we could modify the
return make_response(msg, 201)
to send back a 400 status code with an error log body (ex: as string[]) if something went wrong. we could then tell the JS to present the html alert box with the response error data. (helping the user understand why it crashed without viewing the logs)js example being:
webserver.py (as an example)
index.html
emhass/src/emhass/templates/index.html
Lines 83 to 122 in 78309ad
to
Originally posted by @GeoDerp in #190 (comment)
Some info I found here: https://flask.palletsprojects.com/en/2.3.x/api/#flask.Flask.make_response
The text was updated successfully, but these errors were encountered: