I have a Flask app with a route defined like this:
@app.route("/api/<value>")
def foo(value):
...
On my local machine, using Flask development server, everything works correctly.
But on production, where the app is deployed on IIS using wfastcgi
, I get a 404 error when name
contains non-ascii characters. In IIS logs the route seems OK (shown on the log file as UTF-8) but on the Flask side the request is received with gibberish characters. The following method:
@app.before_request
def log_request():
req: flask.Request = request
logger.info(
f"{req.method} {req.path}}"
)
prints this to the log:
GET /api/�
This is more than just a display issue. The value itself is incorrect and I can't use it to process the request correctly.
I tried to use the quote
and unquote
methods from the urllib
package but it does not seem to solve the problem.
Is there any setting on IIS I can use to fix this?
(IIS 10, Flask 1.1.2)