什么是子域名,我们的后台管理系统, 比如cms.heboan.com。
配置子域名需要用到蓝图技术:

我现在buleprints下面创建一个cms.py 蓝图

from flask import Blueprint


cms_bp = Blueprint('cms', __name__, subdomain='cms')

@cms_bp.route('/')
def index():
    return 'cms page'

在主程序my_flask.py注册该蓝图

...
from blueprints.cms import cms_bp

...
app.register_blueprint(cms_bp)

编辑配置文件config.py添加如下一行

SERVER_NAME = 'heboan.com:5000'

编辑hosts 文件(C:\Windows\System32\drivers\etc\hosts)

#添加此行
127.0.0.1   heboan.com  cms.heboan.com

12、Flask实战第12天:子域名

相关文章:

  • 2021-11-28
  • 2021-06-01
  • 2021-05-07
  • 2021-09-09
  • 2021-07-14
  • 2021-12-31
  • 2021-12-03
  • 2021-08-14
猜你喜欢
  • 2021-04-23
  • 2021-09-23
  • 2021-10-24
  • 2021-11-26
  • 2022-02-11
  • 2021-10-14
  • 2022-12-23
相关资源
相似解决方案