Last active
December 14, 2015 07:59
-
-
Save femmerling/5054458 to your computer and use it in GitHub Desktop.
Editing contact/add routing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route('/contact/') | |
def contact_add_controller(): | |
#this is the controller to add new model entries | |
return render_template('contact_add.html', title = "Add New Entry") | |
@app.route('/contact/create/',methods=['POST','GET']) | |
def contact_create_data_controller(): | |
# this is the contact data create handler | |
contact_name = request.values.get('contact_name') | |
contact_email = request.values.get('contact_email') | |
message = request.values.get('message') | |
new_contact = Contact( | |
contact_id = generate_key(), | |
contact_name = contact_name, | |
contact_email = contact_email, | |
message = message | |
) | |
db.session.add(new_contact) | |
db.session.commit() | |
return return 'Contact message sent <a href="/">back to home</a>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment