I want to match all routes and handle all received HTTP requests in Flask. The code is as follows:
from flask import Flask
from flask import request
app = Flask(name)
@app.route(‘/path:full_path’, methods=[‘GET’, ‘PUT’, ‘DELETE’, ‘POST’])
def catch_all(full_path):
print(request.url)
return request.url
if name == “main“:
app.run(port=8080, host=’0.0.0.0′, ssl_context=’adhoc’, debug=True)
The above code works well except the case that the “static” is in the path. For example, if the url is https://127.0.0.1:8080/static/index.html, then the above code doesn’t work. How to fix this problem?
I try to solve this problem by modifying the code as
app = Flask(name, static_url_path=”)
It still doesn’t work.
user26570422 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.