Forums

New flask app not presenting

I just uploaded a zip, unzipped, and thought I had activated my new web app. But the new app is not showing, I am still seeing "Hello from Flask". I Help!

Have you configured the WSGI file (linked from the "Web" page) to load up your uploaded code?

Thanks for your input. I looked at the WGSI file as you suggested. It looks good to me. I have done some work on the application code and now I have a different error. Following the automatically provided trouble shooting the directions, I tried the following:

03:40 ~/sdb/mysite/Hello (main)$ python -i /var/www/joebonds_pythonanywhere_com_wsgi.py Traceback (most recent call last): File "/var/www/joebonds_pythonanywhere_com_wsgi.py", line 16, in <module> from flask_app import app as application # noqa

I do have flask installed.

Any ideas?

Could you show the full traceback message?

.

03:40 ~/sdb/mysite/Hello (main)$ python -i /var/www/joebonds_pythonanywhere_com_wsgi.py
Traceback (most recent call last):
  File "/var/www/joebonds_pythonanywhere_com_wsgi.py", line 16, in <module>
    from flask_app import app as application  # noqa
ModuleNotFoundError: No module named 'flask_app'

[edit by admin: formatting]

What code do you have in the WSGI file to set up the path? The line that is highlighted is trying to load a Flask app from a file called flask_app.py that is in the directory that is specified there.

Thqnks for all the help.
I have tried to simplify my app.
Now I am getting "jinja2.exceptions.TemplateNotFound: featured.html".
You have permission to access my account.
It would would really help if you can take a look and let me know where I went awry!

Where is featured.html template file?

Thanks.
I apparently deleted my templates and static directories accidentally while simplifying.
I will rebuild and try again.

I have rebuilt.
There now is a templates directory with featured.html in it.
I still get the same error message in the error log.
jinja2.exceptions.TemplateNotFound: featured.html
Please investigate again with my permission to access the account.

Your WSGI file is set up to load the code from /home/joebonds/mysite/Hello. That directory doesn't contain a templates directory -- it looks like you've put that in /home/joebonds/sdb/mysite/Hello instead -- note the extra sdb directory in that path.

Thanks!
Working on it.

I am ready for help again!
werkzeug.routing.BuildError: Could not build url for endpoint 'location'. Did you mean 'static' instead?
You have my permission to access my account. This works on locally on my laptop.

Make sure that you do not have any code that needs to be run in an if __name__ == "__main__" block. Any code in there will not be run when your web app is run.

I do not believe that I have any such occurences.

13:34 ~/mysite $ grep -rnw . -e 'main'
13:35 ~/mysite $

In that case, you are probably just trying to use url_for for an endpoint that you have not defined in your code. Make sure that, if you are using url_for, you are trying to find the url of an endpoint that is defined.

There is a location.html in the templates directory. I tried removing the anchor in base.html that referred to it.
That worked.
Got the error again when I added the anchor back in.
I do not understand why it cannot find it in the temples directory.

22:12 ~ $ cd mysite/Hello
22:12 ~/mysite/Hello $ ls -l templates/location.html
-rw-rw-r-- 1 joebonds registered_users 367 Aug 12 00:54 templates/location.html
22:13 ~/mysite/Hello $ cat templates/location.html
{% extends 'base.html' %}
{% block content %}
<h1>{% block title %} Location {% endblock %}</h1>
<div style="font-size: 20px;margin:30px;">
<br>140 Johnny Mercer Blvd<br>
Savannah, GA 31410<br>
Mercer Plaza inside by the fountain<br>
912-657-2927<br>
<br>
TUES-TH: 8am – 4pm<br>
FRI-SAT: 8am – 2pm<br>
CLOSED SUN-MON<br>
</div>
{% endblock %}

Please tell me where I went wrong.

url_for does not look in templates, it looks in routes that you have defined. You need to define a route for the url that you're trying to look up.

Thank you so much!!!!

It is working!!!!!!

Can I make joebonds.pythonanywhere.com a secure https site?

Sure. Just choose the option on your Web App configuration page.

I am trying to set up a custom domain name.
On namecheap.com I setup a cname with www.chefcharlottesconfections.com as host
and webapp-1802938.pythonanywhere.com as value.
Is this correct?

Have a look at this help page for details -- currently this domain is not pointing to PythonAnywhere; you can check it, for example, here.

Thanks, but that did not help.
I understand now how to use whatsmydns.net.
My question is more specific.
I was trying to follow the help page.
I am using namecheap.
Shoud I use the entire "www.chefcharlottesconfections.com" as the host in the cname record or just "www"?

Hey looks like you got it!

We recomment you use "www." and redirect the naked domain ("chefcharlottesconfections.com") to the www. site

Yes, using just 'www' in the host field of the cname worked.
I just added a redirect from the bare domain to the www name and am now waiting for dns propogation.
Now I am focusing on adding the security certificate and have questions about that:
Do I need to install certbot? How?
At https://certbot.eff.org/instructions I see "My HTTP website is running 'Software' on 'System' '".
How do I fill in Software and System?

You can just enable the certificate from your web app configuration page. You do not need to use certbot yourself.

Thanks that worked. I am still trying to redirect from chefcharlottesconfections.com to
www.chefcharlottesconfection.com

The DNS looks to have been propagated now

The DNS looks to have been propagated now

It is working now. All is well. Thank you!!!
You may close this issue.

Great! Glad you got it working in the end.