Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Flask with SQLAlchemy Basics Creating a Basic Website with Flask Set Up a Form

Inside of the form.html file, you will connect the form to your route. In the <form> tag, set the action attribute with

Please help, why my code is incorrect?

{% extends 'layout.html' %}

{% block content %}
    <form action="{{ url_for('form') }}" method = "POST">
        <input type="text" name="name" id="firstName" placeholder="First Name">
        <label for="firstName">What is your first name?</label>
        <button type="submit">Submit</button>
{% endblock %}
from flask import Flask, url_for, render_template, request

app = Flask(__name__)

@app.route('/form', methods=['GET', 'POST'])
def form():
    return render_template('form.html')

if __name__ == '__main__':
    app.run(host='', port=8000)

1 Answer

Megan Amendola
.a{fill-rule:evenodd;}techdegree seal-36
Megan Amendola
Treehouse Teacher

Hi! You don't want any spaces here <form action="{{ url_for('form') }}" method = "POST"> instead it should be <form action="{{ url_for('form') }}" method="POST">

Works now, thank you. Does it mean "method = "POST" has to be no space or just the design or this question? Thank you