def post(self): parse = parser.parse_args() name = parse.get('u_mail') password = parse.get('u_password') session['u_mail'] = name title = parse.get('b_title') content = parse.get('b_content') blog = Blog() blog.b_title = title blog.b_content = content users = User.query.filter(User.u_mail.__eq__(name)) if users.count() > 0: user = users.first() if user: if check_password_hash(user.u_password, password): db.session.add(blog) db.session.commit() return { 'msg': '登录成功', 'msg1': '博客添加成功', } else: return {'msg': '密码错误'} else: return {'msg': '用户名不存在'} return {'msg': '最后的返回'}
def edit_blog(request): if request.method == 'GET': return render(request, 'edit_blog.html') elif request.method == 'POST': content = request.POST.get('content') blog = Blog() blog.b_content = content blog.save() return HttpResponse('okay')
def edit_blog(request): if request.method == 'GET': return render(request, 'edit_blog.html') elif request.method == 'POST': content = request.POST.get("content") print(content) blog = Blog() blog.b_content = content blog.save() return HttpResponse("哈哈")
def edit_blog(request): if request.method == "GET": return render(request, 'edit_blog.html') elif request.method == "POST": content = request.POST.get("content") print(content) blog = Blog() blog.b_content = content blog.save return HttpResponse('Hahahah')
def edit_blog(request): if request.method == 'GET': return render(request, "edit_blog.html") elif request.method == 'POST': content = request.POST.get('content') print(content) blog = Blog() blog.b_content = content blog.save() return HttpResponse('content obtained!')
def post(self): parse = parser.parse_args() # 解析请求参数 title = parse.get('title') content = parse.get('content') print(title) print(content) # 创建Blog对象 blog = Blog() blog.b_title = title blog.b_content = content try: db.session.add(blog) db.session.commit() except Exception as e: return {'returnCode': '1', 'returnValue': str(e)} return {'returnCode': '1', 'returnValue': blog}
def post(self): parse = parser.parse_args() name = parse.get('u_mail') password = parse.get('u_password') session['u_mail'] = name title = parse.get('b_title') content = parse.get('b_content') modify_title = parse.get('modify_b_title') modify_content = parse.get('modify_b_content') users = User.query.filter(User.u_mail.__eq__(name)) if users.count() > 0: user = users.first() if user: if check_password_hash(user.u_password, password): blogs = Blog.query.filter(Blog.b_title.__eq__(title)) if blogs.count() > 0: blog = blogs.first() db.session.delete(blog) db.session.commit() blog = Blog() blog.b_title = modify_title blog.b_content = modify_content db.session.add(blog) db.session.commit() return { 'msg': '登录成功', 'msg1': '博客修改成功', } else: return {'msg': 'sorry呀,没有这个博客'} else: return {'msg': '密码错误'} else: return {'msg': '用户名不存在'} return {'msg': '最后的返回'}