serverlessplus / flask-example Goto Github PK
View Code? Open in Web Editor NEWserverlessplus flask example
License: Apache License 2.0
serverlessplus flask example
License: Apache License 2.0
你好,我使用这个serverlessplus 在云函数上运行flask app, 路由什么的看起来都是没有什么问题的,但是使用post 方法 传递flask form的数据的时候,云函数接收不到,请问是什么原因,需要怎么做来解决?
我看到post请求的时候是把form表单的数据给发送过去了,但是云函数上无论是requests.form还是form都是没有数据,使用了API网关触发器(勾上了集成响应)。
form.py
from flask_wtf import FlaskForm
from wtforms import StringField, BooleanField, SubmitField, PasswordField, SelectMultipleField, SelectField, FieldList, \
FormField
from wtforms.validators import DataRequired, Length
class LoginForm(FlaskForm):
email = StringField('User', validators=[DataRequired(), Length(1, 64)], render_kw={"placeholder": "请输入用户名", "class": "form-control"})
password = PasswordField('Password', validators=[DataRequired()], render_kw={"placeholder": "请输入密码", "class": "form-control"})
submit = SubmitField('Login', render_kw={'value': '登录'})
view.py
from flask import Blueprint, render_template, redirect, request, url_for
from forms import LoginForm
auth = Blueprint('auth', __name__)
@auth.route('/login', methods=['GET', 'POST'])
def login():
form = LoginForm()
print(request.form)
if form.validate_on_submit():
print(form.email.data)
if form.password.data == '123456' and form.email.data == 'hello':
return redirect(url_for('blogs.blog_list'))
return render_template("/auth/login.html", form=form)
login.html
{% import 'bootstrap/wtf.html' as wtf %}
<!DOCTYPE html>
<html>
<head>
<title>login</title>
</head>
<body>
<p>login</p>
{{ wtf.quick_form(form) }}
</body>
</html>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.