Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8710835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:43:35+00:00 2026-06-13T04:43:35+00:00

I am making a stock application, where, after a user types in a stock

  • 0

I am making a stock application, where, after a user types in a stock such as MSFT, they are redirected to .../stock?s=MSFT 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 MSFT) out if it and save it as a new variable.

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 self.request... but this returned the error:

NameError: global name 'self' is not defined

The other ideas I came across was to use a form of urllib as it contains a specific .request_qs() method, although this requires me to pass the URL as a parameter, which should be unique every time because of the change in stock.

Here is the Python I currently have:

@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"&f=snl1"
    text=urllib2.urlopen(url).read()

    return render_template('stock.html')

Many thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:43:36+00:00Added an answer on June 13, 2026 at 4:43 am
    1. It’s request (imported from the flask package), not self.request

    2. The Flask docs have, as always, thorough documentation about variables in the URL: http://flask.pocoo.org/docs/quickstart/#variable-rules

      @app.route('/user/<username>')
      def show_user_profile(username):
          # show the user profile for that user
          return 'User %s' % username
      

    On that occasion, you should read the whole Quickstart from the Flask docs: http://flask.pocoo.org/docs/quickstart/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Making a simple application, so when the user logs out of Windows, it of
I have an application that I am making an have run into a place
I'm making a tabbed view application and using CloudMade's API. I have a working
I am developing a stock/e-commerce web application. We have been using a version of
I am making a forms application is Visual C#. I have a textbox where
Making a word document of our network set-up. We have about 7 servers and
I am making a QT application that updates the window based on the information
Looking into possibility of making an USB distributed application that will autostart on insertion
I'm making my first iOS application to be run specifically on an iPad as
I am making an application in C that depends on asynchronous method calls. In

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.