Coder Social home page Coder Social logo

flask-example's Introduction

serverlessplus flask 示例

flask-example's People

Contributors

serverlessplus avatar

Stargazers

 avatar  avatar

flask-example's Issues

怎么在使用form?

你好,我使用这个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>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.