上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 23 下一页
摘要: Request ——http请求中的东西,都能从request中取出来 # 请求相关信息 request.method # 提交的方法 request.args # get请求提及的数据 request.form # post请求提交的数据 request.values # post和get提交的数 阅读全文
posted @ 2024-02-29 16:33 wellplayed 阅读(29) 评论(0) 推荐(0)
摘要: FBV写法 from flask import Flask, jsonify app = Flask(__name__) app.debug = True @app.route('/') def index(): return 'hello' CBV写法 # 导入模块 from flask.view 阅读全文
posted @ 2024-02-29 15:40 wellplayed 阅读(32) 评论(0) 推荐(0)
摘要: 配置文件预览 DEFAULT_CONVERTERS = { 'default': UnicodeConverter, 'string': UnicodeConverter, 'any': AnyConverter, 'path': PathConverter, 'int': IntegerConve 阅读全文
posted @ 2024-02-29 15:26 wellplayed 阅读(29) 评论(0) 推荐(1)
摘要: 前置代码 from flask import Flask, jsonify app = Flask(__name__) 1 flask 路由系统是基于装饰器的,但是它的本质是: add_url_rule 2 装饰器的参数及作用 ''' 1 rule : 路径 2 methods: 可以允许的请求方式 阅读全文
posted @ 2024-02-28 16:55 wellplayed 阅读(40) 评论(0) 推荐(1)
摘要: flask的几种配置文件方式 方式一:放在app对象上,本质会放在 app.config 里面 app.secret_key = 'asdfsdf' app.debug = False 方式二:放在app对象的config参数上 app.config['DEBUG'] = True app.conf 阅读全文
posted @ 2024-02-28 16:35 wellplayed 阅读(239) 评论(0) 推荐(0)
摘要: 一 装饰器,需要放在路由装饰器下面 ''' 在执行视图函数之前,做判断--》 路由的装饰器是控制路由匹配的--》 需要先执行,所以登录认证装饰器,需要放在下面 ''' 二 需要直接指定路由别名 原因 ''' 直接添加会报错————每个路由,都会有个别名,如果不写,默认以函数名作为别名 如果视图函数加 阅读全文
posted @ 2024-02-28 16:03 wellplayed 阅读(60) 评论(0) 推荐(0)
摘要: 新手四件套(返回格式) # 导入 from flask import Flask, request, render_template, redirect, session # 返回字符串 return '字符串' # 返回模板 return render_template('模板名字') # 传参 阅读全文
posted @ 2024-02-28 15:51 wellplayed 阅读(34) 评论(0) 推荐(1)
摘要: 开启debug模式的作用 1 浏览器显示错误信息 2 修改代码会自动重启 开启方式 flask --app 文件名.py run --debug # 书写代码开启方式 app = Flask(__name__) app.debug = True 阅读全文
posted @ 2024-02-27 17:08 wellplayed 阅读(174) 评论(0) 推荐(0)
摘要: 方式一(pycharm配置) 首先新建一个flask-server 目标文件选择需要运行的文件地址即可 方式二:命令运行(推荐这种) flask --app 文件名字.py run # 或者 python3 -m flask --app 文件名字.py run 方式三:右键运行 # 必要代码 if 阅读全文
posted @ 2024-02-27 17:04 wellplayed 阅读(899) 评论(0) 推荐(0)
摘要: Mac/linux # 创建虚拟环境 mkdir myproject cd myproject python3 -m venv .venv # 激活虚拟环境 . .venv/bin/activate Win # 创建虚拟环境 mkdir myproject cd myproject py -3 -m 阅读全文
posted @ 2024-02-27 16:53 wellplayed 阅读(40) 评论(0) 推荐(0)
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 23 下一页