🗒️flask 入门

type
status
slug
summary
tags
category
icon
password
Date
最小实现示例
hello.py
templates/hello.html
bash
实际中可能的例子
  • 第一行设置应用的 ENVIRONMENT 配置项。
  • 第二行使用 update 方法更新应用的配置。如果 config 参数为 None,则使用空字典。
  • db.init_app(app): 使用应用实例初始化数据库。
  • admin.init_app(app): 使用应用实例初始化后台管理。
  • app.register_blueprint(index_bp): 注册 index_bp 蓝图,以添加与首页相关的路由。
  • register_processors(app): 调用 register_processors 函数,可能是为了注册一些自定义的模板处理器。
比如,注册一个将日期字符串格式化为更易读格式的处理器
在模板中使用:
 
Loading...

© NotionNext 2021-2025