Hello everyone,
I've been running a Flask app on PythonAnywhere for over a year without any issues. This app handles HTTP requests (both POST and GET) from several field devices. The code on both the server and the field devices has not changed during this period.
However, starting today, all requests from the field devices are being rejected with a "400 Bad Request" error. When I simulate the same requests using Postman, the app responds correctly without any errors.
Here are the steps I've taken so far:
I enabled detailed logging in Flask using the before_request hook to capture request headers and body, but nothing is being logged, which suggests the requests might not even be reaching the Flask app.
Here’s the code snippet I’m using for logging:
@app.before_request
def log_request_info():
app.logger.debug('Headers: %s', request.headers)
app.logger.debug('Body: %s', request.get_data())
There have been no code changes on the server or the field devices. I also checked for any updates or changes in PythonAnywhere that might have affected the environment, but couldn’t find anything obvious.
When I replicate the same request using Postman, the app responds correctly, so it seems the issue is specific to requests from the field devices.
I’m wondering if anyone has encountered a similar issue or if there might be something specific to PythonAnywhere or Flask that I’m missing. Any advice on additional debugging steps or possible causes would be greatly appreciated.
Thank you!