How can I get current base URI in flask?
You can use the base_url
method on flask's request
function.
from flask import Flask, request
app = Flask(__name__)
@app.route('/foo')
def index():
return request.base_url
if __name__ == '__main__':
app.run()
This returns the following if the app route is /foo
:
http://localhost:5000/foo
Use flask.request.url
to retrieve your requested url. Have a look at: http://flask.pocoo.org/docs/1.0/api/#flask.Request (or the v0.12 docs)