Created
August 17, 2016 08:56
-
-
Save swshan/cad69af40c7e5cb9bc03f3be98e1a8bb to your computer and use it in GitHub Desktop.
flask 实现子域名
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from flask import Flask, Blueprint, request | |
app = Flask(__name__) | |
app.config.DEBUG = True | |
#app.url_map.default_subdomain = 'www' | |
app.config['SERVER_NAME'] = 'example.com' | |
@app.route("/", subdomain="<username>") | |
def username_index(username): | |
"""Dynamic subdomains are also supported | |
Try going to user1.your-domain.tld/dynamic""" | |
return username + ".example.com" | |
if __name__ == '__main__': | |
app.run(host='127.0.0.1', port=80, debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment