Domanda

I have a flask app that makes use of a sqlite3 database. When I run the application with in development with debug on, it works exactly as expected.

When running the application with uWSGI, uWSGI Emperor and Nginx, the app runs as expected until I hit a button that causes interaction with the database.

The error is an: Internal Server Error

I am unable to debug the situation because flask does not allow debug mode in production.

I assume the problem is that the application is looking for the static database file in the wrong directory. Where might I place the database so it is found?

Not sure what information to post besides this. Will update if needed.

EDIT: Problem was solved by giving the full path of the database. Is there a way to get a dynamic full path to a file in Flask?

È stato utile?

Soluzione

If you know the relative path to the file, you could use:

import os
abspath = os.path.abspath("mydir/myfile.txt")

to retrieve the files absolute path.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top