老师帮忙看一下,昨天还能运行的文件,怎么今天在运行就出错误了呢,提示是密码,可是我昨天连接数据库就是这个密码,也都增删改查成功了啊。
graphene增删改查与sql.zip
屏幕截图 2021-06-10 103036.png
需要先安装mysql吗
改了端口号之后运行还是5000,去网页里调用也是5000能调
我是继续用我之前下载的pycharm 还是用老师提供的这个?
如果我沿用flask session的默认设置尝试阻止浏览器删除会话级别的session,是否可以实现长期session
from flask import Flask,request,render_template app = Flask(__name__) @app.route('/') def hello_world(): return 'Hello World!' @app.route('/article/<id>/') def list(id): print(id) return 'success your id is %s'%id @app.route('/article2/<uuid:id>/') def list2(id): print(id) return 'success your id is %s'%id # import uuid # print(uuid.uuid4()) #@app.route('/list7')#这种写法方式只支持get请求方式 不支持post请求方式 @app.route('/list7',methods=['GET','POST'])#这种写法方式支持get请求方式 支持post请求方式 def list7(): if request.method=='GET': pwd = request.args.get('pwd') uname = request.args.get('uname') # return 'success: %s ,%s'%(uname,pwd) return render_template('login.html') elif request.method=="POST": uname=request.form.get('uname') pwd=request.form.get('pwd') return 'post请求成功: %s ,%s'%(uname,pwd) if __name__ == '__main__': app.run(debug=True)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <h4>登陆页面</h4> <form action="/list7" method="post"></form> 用户名:<input type="text" name="uname"><br> 密 码:<input type="password" name="pwd"><br> <input type="submit" value="登录"> </body> </html>
为什么点击登录没有反应
做表单验证是这个Email报错,email_validator模块也找不到
老师,您看这个错误是什么原因呀,我上网查了也没找到解决的办法?麻烦老师了
添加这个类和注册成功后:
class JsonResponse(Response): @classmethod def force_type(cls, response, environ=None): if isinstance(response, dict): jsonResponse = jsonify(response) return super(JsonResponse, cls).force_type(jsonResponse) app.response_class = JsonResponse
返回Response封装好的对象会报错:
@app.route('/') def hello_world(): return Response("返回一个Response对象")
直接 return "返回一个Response对象" 是好的
我输入网址老是失败,这是什么原因呢
flask Flask werkzeug.routing BaseConverter app = Flask(__name__) @() hello_world(): @() profile (id): %id TelephoneConverter(BaseConverter): regex = app.url_map.converters[]=TelephoneConverter @() my_phone(num): %num __name__ == : app.run(=)
老师通过这个报错信息,我发现视图函数的返回值是支持字典类型的,但是列表等等一些还是不支持的,我有点搞不清楚,什么时候返回的就是response这个对象,字符串,元组这种类型的符合response对象,但是如果返回的是一个xxx.html也符合,那是只有通过视图函数去返回,然后验证他是属于response这个对象么。
虚拟环境与虚拟机有什么区别?是什么关系?
老师Flask中的类视图中的函数是不是分为几类呀,里面的函数方法的名字是固定的,如def get()或def post()就只能这么取,而且只能应用在form表单提交数据类型时,才会响应这些改写的函数方法。
而def dispatch_request()这个函数方法是在应用类视图中,最先开始的函数方法。
其他那些自己定义名字的函数方法,只能通过这些固定的函数方法返回才能使用呀
老师,我想问下 json对象和转换 之前学过吗?我好像没什么印象
老师,uri和url有啥区别吗
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637