Hey guys, I'd like to thank you for your help in advance. I am new to programming, and am now stuck at the end of sentdex's 2'nd Flask tutorial video, when I try and connect to my server via the address bar in the browser it gives me an "internal server error" page. Now I'm assuming, this tells you all absolutely nothing :P Just curious if anyone has any ideas on what could be wrong, I'm pretty darn sure I followed instructions correctly. Except.... I don't think this would matter, but I ended up making a server with Linode rather than Digital Ocean. Thanks again, Oh and by the way, Thanks for the tutorials :)
You must be logged in to post. Please login or register an account.
Could be a few things wrong. The good news is, they are almost all simple fixes.
When this happens, you need to determine if it's an error in the HTML template, or in the python init.py file.
To figure out if its a code error, simply run:
python __init__.py
in the console, and see if any errors, such as syntax errors come up.
If not, next, go to your definition for the index page, and encase it in a try/except, where the the exception is like:
except Exception as e: return str(e)
If you do that, now, rather than a meaningless 500 error, you will get the actual python error and then you can fix accordingly.
-Harrison 9 years ago
You must be logged in to post. Please login or register an account.
Thank's for the quick response, you're awsome man, I now have it so that when I try to goto the server via web browser, it gives me the "apache ubuntu default page" which says apache is running and whatnot. When I run python __init__.py outside of the virtual environment we created, it gives me an Import error saying no module named Flask, but if I have the virtual environment activated it runs as it should.
I think I need to whitelist my document root directory in /etc/apache2/apache2.conf. ?
-GreyValleys 9 years ago
Last edited 9 years ago
You must be logged in to post. Please login or register an account.
If you are just getting the apache page, then you need to make sure you set up the flaskapp.conf file correctly.
In the console:
nano /etc/apache2/sites-available/FlaskApp.conf
Then edit that to be:
<VirtualHost *:80> ServerName yourdomain.com ServerAdmin youemail@email.com WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi <Directory /var/www/FlaskApp/FlaskApp/> Order allow,deny Allow from all </Directory> Alias /static /var/www/FlaskApp/FlaskApp/static <Directory /var/www/FlaskApp/FlaskApp/static/> Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
...making sure to replace yourdomain.com with your actual domain.
-Harrison 9 years ago
You must be logged in to post. Please login or register an account.
I was getting the ubuntu page because I was messing with server name, I put it back to normal and I'm back to the 500 page. Sorry, but where is my "definition for the index page"? I'm trying to google, but I don't think I know how to ask it the right question here, thanks again
-GreyValleys 9 years ago
You must be logged in to post. Please login or register an account.
I was having a similar problem today. I destroyed the droplet and followed the installation process again and it seemed to work. You could trace your error by putting in your IP and making sure you know what change is provoking 500 error by going to your IP after making changes too.
-devtycoon 9 years ago
You must be logged in to post. Please login or register an account.