0

I have spent three days on learning the code in pset7 but i still have few questions.

1) In here:

# configure session to use filesystem (instead of signed cookies)
app.config["SESSION_FILE_DIR"] = mkdtemp()
app.config["SESSION_PERMANENT"] = False
app.config["SESSION_TYPE"] = "filesystem"
Session(app)

the program creates session FILE that must store the data on the server(in my folder) but even if i run the program this file doesn't show up. Where is my user_id is saved then if i can't see the file that the session should create?

2) In helpers.py in "lookup" function the following code:

# return stock's name (as a str), price (as a float), and (uppercased) symbol (as a str)
return {
    "name": row[1],
    "price": price,
    "symbol": row[0].upper()
}

returns a dictionary with the name of the company, but in the csv file that i'he downloaded there is no name of the company. Here's what in this file:

"NFLX",195.50,"10/20/2017","10:01am",+0.37,195.90,196.38,194.85,1053447

See? No "Netflix, Inc." but when i run the program it does magicaly returns me "Netflix, Inc." when i ask for "name" in the returned dictionary. How is that possible?

1
  1. mkdtemp creates a directory in your temporary directory (most likely /tmp), there you'll find the files after login. They aren't removed on closing the server.

  2. The code uses URL http://download.finance.yahoo.com/d/quotes.csv?f=snl1&s=NFLX where I see "NFLX","Netflix, Inc.",194.7899

2
  • Thanks! About 2. in the cs50 pset7 tutorial there is this link: (download.finance.yahoo.com/d/…) that hasnt the name, but in the code they use the right one: (download.finance.yahoo.com/d/quotes.csv?f=snl1&s=NFLX). I think they need to change the tutorial text, because it can confuse someone else. – Ruslan Plastun Oct 20 '17 at 18:12
  • That part lies in the f parameter. snl1 means symbol, name, last trade (price only). sl1d1t1c1ohgv means symbol, last trade (price only), last trade date, last trade time, change, open, day's high, day's low, volume. So you see, no n for name. The sl1d1t1c1ohgv string seems to be used frequently, so it's a more realistic example on how to use the API. – Blauelf Oct 20 '17 at 18:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .