Posts

Showing posts with the label flask

import .py file from parent directory in flask project

I meet an issue from the beginning of my flask project. my project is like : ps:run.py, the folder fbapp/, and config.py is in the project/ folder when I execute views.py, i got the error : It resolve when I move the config.py file in the fbapp/ directory, but It will lead some probleme when I will use SQLAlchemy library. I need to have config.py and run.py in the same directory. views.py : config.py : __init__ .py : thank you in advance here the whole project :https://github.com/oc-courses/concevez_un_site_avec_flask/tree/P1C2 you must add: __init__.py (empty) file to your package otherweise you cannot find the module: if you dont 'declare' a folder as python module, you cannot import from it so in views.py you'll have to do : from fbapp.config import <what you need> PS: my suggestion, in python is to create 'modules' by IDE interface, so the IDE itself will bother with this. By clicking "Post Your Answer...