How do you load information into a database using flask?
<p>Trying to teach myself flask by making a web app. I'm having trouble posting inputs from the user to my dataBase and when I load the page and then try to submit info through my form I get this 405 error:</p>

<p>"GET / HTTP/1.1" 200 -,</p>

<p>"POST / HTTP/1.1" 405 -</p>

<p>Any insight would be greatly appreciated, Thanks. </p>

<p>Here is the python snippet:</p>

<pre><code>session = DBSession()

app = Flask(__name__)

@app.route('/')
def index(methods=['GET','POST']):
    print request.method
    if request.method == 'POST':
        instances = session.query(Vocab)
        newItem = Vocab(id=len(instances), word=request.form['new_word'])
        session.add(newItem)
        session.commit()
    instances = session.query(Vocab)
    return render_template('vocab_template.html', instances = instances)
</code></pre>

<p>The html template: </p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
 &lt;head&gt; 
  &lt;title&gt;Vocab&lt;/title&gt;
 &lt;/head&gt;

 &lt;body&gt;
  &lt;div&gt;
   &lt;h1&gt;Words!&lt;/h1&gt;
   &lt;ul id='Words'&gt;
    {% for i in instances %}
     &lt;li&gt;
     {{i.word}}     
     &lt;/li&gt;
    {% endfor %}
   &lt;/ul&gt;
   &lt;form action="/" method="post"&gt;
    &lt;input type="text" name='new_word'&gt;
    &lt;input type="submit" value="Add" name='submit'&gt;
   &lt;/form&gt;
  &lt;/div&gt;
 &lt;/body&gt;

&lt;/html&gt;</code></pre>
</div>
</div>
</p>