[Flask] How to handle sent data through a form (post request) Flask-{Admin, Security}

Unai Rodriguez unai at sysbible.org
Tue Jan 26 11:27:41 EST 2016

Dear List,

I am trying to build a simple web admin interface where users will be
able to register and login to see some details of their account, etc.

I have started by modifying the following Flask-Security example which
basically makes it easy to have all typical views: register, login,
forgot password, etc...


I am having a hard time implementing the register page since it needs to
be integrated with a payment gateway that requires that the server
submits some information to their servers once the user has entered the
data. The idea is simple: a user enters basic information including some
credit card details on the register form which all gets sent to our
server through a post request. The thing is we will probably not store
the credit card details on the database but use this information to
create a transaction on the payment gateway. So I need a way of having
access to the data sent by this post request and not to store it on the
database (and perform some other actions).

This is how my form class has been defined:

class ExtendedRegisterForm(RegisterForm):    # Fields    plan =
SelectField('Plan', choices=[('alpha','alpha ($6.99)'),('gamma','gamma
($14.99)'),('beta','beta ($29.99)')])    cc_number = StringField('Card
number', render_kw={'maxlength':'19'})    cc_name = StringField('Name on
card', render_kw={'maxlength':'50'})    cc_exp_month =
StringField('month', [InputRequired(), Length(min=2, max=2)],
render_kw={'maxlength':'2'})    cc_exp_year = StringField('year',
render_kw={'maxlength':'4'})    cc_cvv = StringField('cvv',

How can I handle the post request? I've tried this but doesn't
seem to work:

@app.route('/admin/register', methods=['POST']) def register():
return render_template('thanks.html')

Is it worth using this Flask-{Admin,Security} modules for what I'm
trying to do or you'd rather just do it from scratch?

Thank you so much

-- unai
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20160127/37f6deba/attachment.html>

More information about the Flask mailing list