I had the following issue with my flask application. I have the following file structure as follows. It seems the internal file include is not working. Can anyone please help me to sort out the issue. I am bit new to python and flask.
app.py, db.py, blacklist.py
all are only in the root directory.
=====app.py=====
import flask
from flask_restful import Api
from flask_jwt_extended import JWTManager
from db import db
from blacklist import BLACKLIST
app = flask.Flask(__name__)
app.config["DEBUG"] = True
@app.route('/', methods=['GET'])
def home():
return "<h1>Api Testing</h1><p>This is just testing endpoint.</p>"
app.run()
====db.py====
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
====blacklist.py====
BLACKLIST = set()
flask.cli.NoAppException
flask.cli.NoAppException: While importing "xxxxxxx.app", an ImportError was raised: Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/flask/cli.py", line 240, in locate_app __import__(module_name) File "/Users/xxxxx/Documents/Vhosts/xxxxx/app.py", line 5, in <module> from db import db ModuleNotFoundError: No module named 'db'