I want to detect if the request came from the localhost:5000<\/code> or
foo.herokuapp.com<\/code> host and what path was requested.
How do I get this information about a Flask request?
"
You can examine the url through several Request<\/code><\/a> fields:
"
another example:
curl -XGET http://127.0.0.1:5000/alert/dingding/test?x=y
you should try:
request.url
If you are using Python, I would suggest by exploring the request object:
I use it to log 404 codes in Flask:
@app.errorhandler(404)
def not_found(e):
with open("./404.csv", "a") as f:
f.write(f'{datetime.datetime.now()},{request.__dict__}\n')
return send_file('static/images/Darknet-404-Page-Concept.png', mimetype='image/png')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.