上一页 1 2 3 4 5 6 7 8 9 10 ··· 41 下一页
摘要: 1 request对象 1.1什么是request对象? request对象封装解析了请求报文中的数据,其大部分功能是由依赖包werkzeug完成的,并且每个request对象都是线程隔离的,保证了数据的安全性。 1.2为什么要有request对象? request对象解决了很多问题,各种请求的方法 阅读全文
posted @ 2022-03-22 23:19 甜甜de微笑 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 1 反向解析 djangoflask reverse url_for 2 自定义转换器 1 写类,继承BaseConverter2 注册:app.url_map.converters['regex'] = RegexConverter3 使用:@app.route('/index/<regex("\ 阅读全文
posted @ 2022-03-22 23:16 甜甜de微笑 阅读(43) 评论(0) 推荐(0) 编辑
摘要: 1 CBV的写法 # -*- coding: utf-8 -*- # @Time : 2021/12/5 17:08 # @Author : dzg from flask import Flask, views app = Flask(__name__) class IndexView(views. 阅读全文
posted @ 2022-03-22 23:15 甜甜de微笑 阅读(79) 评论(0) 推荐(0) 编辑
摘要: @app.route和app.add_url_rule参数: 1 rule URL规则 2 view_func 视图函数名称 3 defaults = None, 默认值, 当URL中无参数,函数需要参数时,使用defaults = {'k': 'v'} 为函数提供参数 4 endpoint = N 阅读全文
posted @ 2022-03-22 23:15 甜甜de微笑 阅读(628) 评论(0) 推荐(0) 编辑
摘要: 1 默认method是get main.py from flask import Flask, request, render_template, redirect app = Flask(__name__) @app.route('/login') def login(): if request. 阅读全文
posted @ 2022-03-22 23:13 甜甜de微笑 阅读(31) 评论(0) 推荐(0) 编辑
摘要: flask配置文件 flask中的配置文件是一个flask.config.Config对象(继承字典),默认配置为: { 'DEBUG': get_debug_flag(default=False), 是否开启Debug模式 'TESTING': False, 是否开启测试模式 'PROPAGATE 阅读全文
posted @ 2022-03-22 23:12 甜甜de微笑 阅读(299) 评论(0) 推荐(0) 编辑
摘要: # response对象 -直接返回字符串 》django的HTTPResponse -render_template >django的render 》返回模板 -redirect >django的redirect 》返回重定向 -jsonfy >django的JsonResponse 》返回jso 阅读全文
posted @ 2022-03-22 23:06 甜甜de微笑 阅读(35) 评论(0) 推荐(0) 编辑
摘要: 比django中多可以加括号,执行函数,传参数 1 项目路径下新建templates文件夹 class Flask(Scaffold): def __init__( self, import_name: str, static_url_path: t.Optional[str] = None, st 阅读全文
posted @ 2022-03-22 23:02 甜甜de微笑 阅读(40) 评论(0) 推荐(0) 编辑
摘要: 1 pycharm新建项目 注意 如果找不到虚拟环境路径可以参考虚拟环境其他命令 lsvirtualenv # 列出所有的虚拟环境 workon flaskenv # 切换到指定的虚拟环境 cdvirtualenv # 切换到指定的虚拟环境路径 该目录就是我们所要的路径 2 第一个flask程序 f 阅读全文
posted @ 2022-03-22 23:00 甜甜de微笑 阅读(36) 评论(0) 推荐(0) 编辑
摘要: 1 Werkzeug简介 Werkzeug是一个WSGI工具包,他可以作为一个Web框架的底层库。这里稍微说一下, werkzeug 不是一个web服务器,也不是一个web框架,而是一个工具包,官方的介绍说是一个 WSGI 工具包,它可以作为一个 Web 框架的底层库,因为它封装好了很多 Web 框 阅读全文
posted @ 2022-03-22 23:00 甜甜de微笑 阅读(382) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 10 ··· 41 下一页