title: How can I get a parameter passed in the url?
body: <p>I am making a stock application, where, after a user types in a stock such as <code>MSFT</code>, they are redirected to <code>.../stock?s=MSFT</code> I have successfully made this part, but now I need Python to grab this current, unique URL so that I can parse the quote (in this case, the <code>MSFT</code>) out if it and save it as a new variable. </p>
  
  <p>The easiest way I can think of is just to get the current URL, although I cannot seem to find a way to do this; using <code>self.request...</code> but this returned the error: </p>
  
  <pre><code>NameError: global name 'self' is not defined
  </code></pre>
  
  <p>The other ideas I came across was to use a form of <code>urllib</code> as it contains a specific <code>.request_qs()</code> method, although this requires me to pass the URL as a parameter, which should be unique every time because of the change in stock. </p>
  
  <p>Here is the Python I currently have:</p>
  
  <pre><code>@app.route('/', methods=['GET', 'POST'])
  def home_search():
      if request.method == 'POST':
              st = request.form['s']
              return redirect(url_for('stock')+'?s='+st)
  
      return render_template('stk.html') 
  
  @app.route('/stock', methods=['GET', 'POST'])
  def stock():
      #here I need to save the variable 'name' as the current URL. I can parse it later.
      url="http://finance.yahoo.com/d/quotes.csv?s="+name"&amp;f=snl1"
      text=urllib2.urlopen(url).read()
  
      return render_template('stock.html')
  </code></pre>
  
  <p>Many thanks in advance.</p>