Adding URL parameters to form action in flask
<p>Is there a way to pass an additional list of parameters outside of a form when the form is submit? </p>

<p>I know I can create a new hidden input field in the form for each parameter I want to pass through the form, but is there another way? I tried to add parameters directly to the form action but that doesn't work. The code in its entirety can be found here:</p>

<pre><code>from flask import Flask, request
import os

app = Flask(__name__)

@app.route('/')
def index():
  print request.args
  return "&lt;form action='/?foo=bar'&gt;&lt;input name='variable' type='text' /&gt;&lt;/form&gt;"

if __name__ == '__main__':
  port = int(os.environ.get('PORT', 8080))
  app.run('0.0.0.0', debug=True, port=port)
</code></pre>

<p>Clarifying question based on feedback from comments:</p>

<p>Using this code, when I type "123" into the textbox and hit enter, I see that the url is <code>http://wardrobe-plus-jeffhou.c9users.io/?variable=123</code>.</p>

<p>What I want is <code>http://wardrobe-plus-jeffhou.c9users.io/?foo=bar&amp;variable=12ââ3</code>.</p>

<p>I think you should show what you input and what you want output.</p>

<p>In your code, the <code>index()</code> function default accept the <code>GET</code> method, so if you want to post data from form add the <code>methods</code> to the <code>@app.route()</code>.</p>

<pre><code>@app.route('/', methods=['GET', 'POST'])
</code></pre>

<p>and, the form also should add post method.</p>

<pre><code>&lt;form method='post', action='/'&gt;&lt;/form&gt;
</code></pre>

python forms flask