我一直在关注这篇文章中提供的方法: https://stackoverflow.com/questions/12167729/flask-subdomains-with-blueprint-getting-404
以下是我的相关代码:
__初始化__。PY
from flask import Flask, render_template
app = Flask(__name__, static_url_path="", static_folder="static"
import myApp.views
views.py
from flask import Flask, render_template, request, Blueprint
from myApp import app
app.config['SERVER_NAME'] = 'myapp.com'
app.url_map.default_subdomain = "www"
@app.route("/")
def index():
return "This is index page."
test = Blueprint('test', 'test', subdomain='test')
@test.route("/")
def testindex():
return "This is test index page."
app.register_blueprint(test)
if __name__ == "__main__":
app.run()
使用这种方法,我可以获得子域名' test'和' www'工作,但现在我无法通过IP地址访问我的网站。
任何对正确方向的指导都将不胜感激!