@app.route( /login , methods=[ GET , POST ]) deflogin(): if request.method == POST : do_the_login() else: show_the_login_form()
4.5 套用模版
回复的时候为了可以套入模版,可以使用render_template方法。
需要将模版放在文件夹/templates/中。
case 1:a module:
1 2 3
/application.py /templates /hello.html
case 2:a package
1 2 3 4
/application /__init__.py /templates /hello.html
4.6 读取请求数据
flask中使用的是全局的request object,但它本身是线程安全的。
4.6.1 Context Locals
此处暂时没懂。
4.7 错误
可以使用模版来自定义错误界面。
8.4 其它模块的日志
当有其它模块的时候,为了让它的log也能写进来,可以使用下面的代码。
1 2 3 4 5
from logging import getLogger loggers=[app.logger,getlogger('sqlalchemy'),getLogger('otherlibrary')] for logger in loggers: logger.addhandler(mail_handler) logger.addHandler(file_handler)
文章
sync local with remote by vscode
I want to use vscode as my main code editor.I need to sync my code from local to the remote GPU server.I choose to use sftp extensions in vscode.After
Setup the LaTeX environment in vscode
I want to give up texstudio in my Mac due to its ugly GUI. OS macOS 10.14.2 Setup Steps Install MacTex. Do not update package in default setting espec
Extending Neural Generative Conversational Model using External Knowledge Sources
文章总结的两点还挺有意思的 用基于连接的方法来做对话是因为有大规模的语料 之前几年的对话系统研究都集中在把所有的组件都替换一遍。 工作中用了 wikipedia summaries NELL knowledge base related work中列觉了很多利用外部知识的对话系统的工作 这个工作中把