Quantcast
Channel: Planet Python
Viewing all articles
Browse latest Browse all 22462

Stories in My Pocket: New python web app not working?

$
0
0

How many times have you had the thrill of releasing a new service or app to the world, only to have it crashing down when you test the URL and find a server error page instead of your work? Here are a few tips I use when I'm trying to figure out why the new python service I have set up is not working:

Check server logs

Many times, there's an error with the Apache config file. There's no guarantee that it'll show up in the logs, but it's a great place to start.

Create a python log

If it seems everything is working well from your server configuration, set up a temporary log in your file that handles the wsgi connection. Below is an example of a logger for a django app. Bold text shows the logging additions.

html
import logginglogging.basicConfig(filename="/path/to/newapp.log", level=logging.DEBUG)


from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "website.settings.production")

application = get_wsgi_application()
logging.debug(application)
alignment
normal

Opening a new terminal window and typing `tail -f /path/to/newapp.log` will give you a view into what's going on.

Sadly, this doesn't always provide a clear pointer to what's going on, but it's a great place to start.

And if you ever get an issue where the service is complaining that something is wrong in one of python's core modules, triple check that your application folder is set to accept traffic.

html
Require all granted
alignment
normal

Do you have any other tips that work better than these? Please let me know!


Viewing all articles
Browse latest Browse all 22462

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>