Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Remove undefined timenow in 001-004-flask-intro #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
bbelderbos merged 2 commits into talkpython:master from serixscorpio:flask-intro-fix
Mar 17, 2021

Conversation

@serixscorpio
Copy link
Contributor

@serixscorpio serixscorpio commented Mar 17, 2021

I came across the following error when I was playing around with the code. Not sure if this error is by design.

[2021年03月17日 06:27:03,870] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
 File "/home/eric/code/serixscorpio/100daysofweb-with-python-course/days/001-004-flask-intro/code/venv/lib/python3.9/site-packages/flask/app.py", line 2447, in wsgi_app
 response = self.full_dispatch_request()
 File "/home/eric/code/serixscorpio/100daysofweb-with-python-course/days/001-004-flask-intro/code/venv/lib/python3.9/site-packages/flask/app.py", line 1952, in full_dispatch_request
 rv = self.handle_user_exception(e)
 File "/home/eric/code/serixscorpio/100daysofweb-with-python-course/days/001-004-flask-intro/code/venv/lib/python3.9/site-packages/flask/app.py", line 1821, in handle_user_exception
 reraise(exc_type, exc_value, tb)
 File "/home/eric/code/serixscorpio/100daysofweb-with-python-course/days/001-004-flask-intro/code/venv/lib/python3.9/site-packages/flask/_compat.py", line 39, in reraise
 raise value
 File "/home/eric/code/serixscorpio/100daysofweb-with-python-course/days/001-004-flask-intro/code/venv/lib/python3.9/site-packages/flask/app.py", line 1950, in full_dispatch_request
 rv = self.dispatch_request()
 File "/home/eric/code/serixscorpio/100daysofweb-with-python-course/days/001-004-flask-intro/code/venv/lib/python3.9/site-packages/flask/app.py", line 1936, in dispatch_request
 return self.view_functions[rule.endpoint](**req.view_args)
 File "/home/eric/code/serixscorpio/100daysofweb-with-python-course/days/001-004-flask-intro/code/program/routes.py", line 7, in index
 return render_template('index.html', title='Template Demo', time=timenow)
NameError: name 'timenow' is not defined

This is to fix "NameError: name 'timenow' is not defined".

This is to fix "NameError: name 'timenow' is not defined"
Copy link
Collaborator

@bbelderbos bbelderbos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, please see my comment with suggested change.

@app.route('/index')
def index():
return render_template('index.html', title='Template Demo', time=timenow)
return render_template('index.html', title='Template Demo')
Copy link
Collaborator

@bbelderbos bbelderbos Mar 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch, thanks @serixscorpio.

Rather than deleting the variable could you actually set the time (datetime.now() I guess), because I see this in the program/templates/index.html template when I fork the repo: <h1>Hello! The current date is {{ time }}</h1> (and the related video might show the same). Thanks.

Copy link
Contributor Author

@serixscorpio serixscorpio Mar 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I didn't notice time is used. Fixed in 511d080

bbelderbos reacted with thumbs up emoji bbelderbos reacted with rocket emoji
Copy link
Collaborator

@bbelderbos bbelderbos Mar 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@bbelderbos bbelderbos merged commit 49dd8f7 into talkpython:master Mar 17, 2021
@serixscorpio serixscorpio deleted the flask-intro-fix branch March 17, 2021 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@bbelderbos bbelderbos bbelderbos approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /