Flask subdomain variable not captured, other routes 404

I am trying to use the Flask subdomain parameter, but have some problems.

I configured the local file / etc / hosts / file to point example.com and blog.example.com to 127.0.0.1.

For the ' index route, the subdomain parameter is not captured when I look at http://blog.example.com//000 . When I try to print var , it prints "var is".

The " login " route is 404s, but I cannot understand why. Any help would be greatly appreciated!

 from flask import Flask app = Flask(__name__) app.debug=True app.config['SERVER_NAME'] = 'example.com' # prints "var is <invalid>" @app.route('/', subdomain="<var>", methods=['GET']) def index(var): print "var is %s" % var return "Hello World %s" % var # This 404s @app.route('/login/', methods=['GET']) def login(): return "Login Here!" if __name__ == '__main__': app.run(host='example.com', debug=True) 
+4
source share
1 answer

You need to specify the port number in the SERVER_NAME configuration.

 app.config['SERVER_NAME'] = 'example.com:5000' 

Must fix it.

+3
source

Source: https://habr.com/ru/post/1490611/


All Articles