8
votes
Runtime Error: API_KEY not set
This can be easily solved by noting which terminal the export command was executed in the same terminal window that flask is running in (will be prompted to run in after the export command). Otherwise,...
7
votes
Accepted
IndexError in initial state of pset6 Sentiments
This command pip3 install --user -r requirements.txt --upgrade solves the problem according to this post on reddit (and the comments here :).
7
votes
Instance of 'scoped_session' has no 'commit' member
They are warnings from pylint.
You can tell pylint to ignore that error by create file .pylintrc in your folder
with contains:
ignored-classes=SQLObject,Registrant,scoped_session
reference link:
...
6
votes
Accepted
How to get a value using flask, from a selected option in a drop down list?
Give your select a name, and your options a value each.
<select class="form-control" id="rating" name="rating">
<option value="5">5</option>
<option value="4">4</...
4
votes
Accepted
cs50 finance / pset-7 confused on index() table
Since "stocks" are in one list and "currentprices" are in another list you will get this result when you use two lists and two loops.
One solution would be to use one loop and use currentprices[i] ...
4
votes
Accepted
Using jinja to render template based on previous url - pset7 finance
Inside the function for the respective routes you can just call the function "flash(message)" before the "return redirect()" function, where "message" is the message you want to display. for example:
...
4
votes
Accepted
jsonify not working when I add this line of code <<db = SQL("sqlite:///mashup.db")>> to application.py
So it seems the workaround solution was to add
app.config['JSONIFY_PRETTYPRINT_REGULAR'] = False
somewhere after the
app = Flask(__name__)
The issue has been reported (https://github.com/pallets/...
3
votes
Accepted
Pset7, Index: How to use loops in Python and Jinja?
The for loop is working and is displaying exactly the data it has. And it technically (theoretically?) is identical to a for loop in C. Perform this code x times. Syntactically, you (normally) tell C ...
3
votes
Web CS50 Project 1: 'flask.cli.NoAppException' flask app with sqlalchemy
Try to delete the following code in line 17.
Session(app)
At least it works for me in Mac.
2
votes
Using jinja to render template based on previous url - pset7 finance
How about if you create a new session key, like session['action'] = 'Bought' that gets set in the appropriate route?
2
votes
Accepted
Help needed for CS50 IDE flask server
Change the call from flask run to flask run --host=0.0.0.0 --port=8080 and it should work, as per this reddit post.
2
votes
Accepted
How to pre-populate sell() and buy() forms from index - Pset7
The "something like" syntax in this call for the href attribute was wrong and has been corrected. It is more something like href="{{ url_for('buy', symbol=stock.symbol ) }}". stock....
2
votes
Accepted
"flask run" error in pset6 sentiments
From the FAQs in the spec:
OSError: [Errno 98] Address already in use
If, upon running flask, you see this error, odds are you (still) have flask running in another tab. Be sure to kill that other ...
2
votes
What is a web server?
https://en.m.wikipedia.org/wiki/Web_server
A web server is server software, or hardware dedicated to running said software, that can satisfy World Wide Web client requests. A web server can, in ...
2
votes
2
votes
Accepted
Flask Sessions Not Working
Try setting the first conditional in your index function to:
if session.get("notes") is None:
This way you will only reset the session's collection of notes when it actually did not yet exist.
At ...
2
votes
Accepted
Is there a way in jinja to display a block in a specific page?
jinja handles conditionals. One possible solution: Add a conditional in the <footer> block and send an indicator when the profile page is rendered. Sample html code:
<footer>
{% if ...
2
votes
Lab9 -- Buttons to delete DB entries don't work
One problem is the html sends person.id as a list ( value="{{ [person.id] }}) so it will never find a match in the db.
Once that is fixed another problem will be discovered: it will not add ...
2
votes
TypeError: 'NoneType' object is not subscriptable in PSET9, but working manually
I noticed that the issue lies in the line where I insert the stock symbol into the "stocks" table in the buy function. The problem is that I am passing stock["name"] instead of ...
1
vote
Should my distances function return the matrix in PSET6?
Your matrix needs to have len(a) + 1 rows of len(b) + 1 cells. The final distance is found in matrix[len(a)][len(b)], which does not exist in your current matrix. A cell matrix[row][col] corresponds ...
1
vote
Accepted
PSET 7 - Finance - application.py
I'm not certain, but I'd venture to guess that it's for development purposes. You don't want caching to happen because your latest changes may not be reflected on the page; and as for storing the ...
1
vote
Pset7 - Finance (register function) - creating internal server error
You are missing the ) for your db.execute statement. Count the opening and closing parentheses.
1
vote
Accepted
Check50 returning error pset7 register
if request.form.get("username") != True or request.form.get("password") != True or request.form.get("password") != request.form.get("confirmation"):
request.form.get("username") and request.form.get("...
1
vote
Accepted
expected 400 but got 200 OK?
I do not think the problem is in register function or register.html. I ran them through check50 and they passed. A little detail I missed on the initial read was "got 200 in all my apology pages", all ...
1
vote
Problem with flask
Search your flask script for --with-threads
According to flask quickstart when running flask run your app will execute the FLASK_APP script so it appears you'll need to check that—whatever your app's ...
1
vote
Accepted
Pset7, Index, why does it not show other stocks i own?
This sql "SELECT symbol, price, name, SUM(shares) AS quanties FROM shares WHERE id=:id" always returns one row. Try it in sqlite3/phpliteadmin. You need a GROUP BY clause . Since you (presumably) want ...
1
vote
Pset 7, why does session["user_id"] not take a variable?
Control will reach db.execute("INSERT INTO users..... when username does not exist in the database. If username does not exist in the database, that means exist is an empty list because the SELECT ...
1
vote
Accepted
Where is session file and where is company's name in csv file?
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.
The code uses URL http://download....
1
vote
Accepted
What is next parameter in the url_for function?
url_for accepts additional arguments that are used as GET parameters (look at the URL it redirects you to if you're not logged in). Your login template might pass those, and after successful login you ...
1
vote
Accepted
What is cache and how could you stop it?
Those are HTTP-Headers. The app uses them to tell the HTTP client (your browser) not to cache the response (otherwise the browser might try to reuse a response instead of doing the same request again)....
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
flask × 118python × 42
finance × 28
pset7 × 25
html × 13
jinja × 13
final-project × 11
pset9 × 10
cs50x × 9
cs50-web-programming-with-python × 9
sql × 8
sqlite × 6
pset6 × 5
pset8 × 5
javascript × 5
flask-sqlalchemy × 5
cs50-ide × 4
json × 4
postgresql × 4
session × 4
check50 × 3
error × 3
register × 3
project1 × 3
cs50web × 3