So I'm trying to graduate from the single file application and organize my flask app for scalability. However, I can't even get past running the server... I tried duplicating exact stackoverflow questions that have had similar troubles before, but no luck, i.e. Structure Flask-Restful API to use SQLAlchemy, python flask-restful cannot get app access in resource class.
I got a regular flask app to work following this structure: http://flask.pocoo.org/docs/0.10/patterns/packages/, however, I have a restful extension that I'm trying to structure, and it's not working.
The error I am getting is:
from yourapplication.resources.foo import Foo
ImportError: No module named resources.foo
My directory structure is:
/myapp
runserver.py
/venv
/yourapplication
init.py
api.py
/resources
foo.py
In runserver.py, I have:
from yourapplication import app
app.run(debug=True)
For init.py, I have:
from flask import Flask
app = Flask(__name__)
import yourapplication.api
lastly, for foo.py, I have:
from flask_restful import Resource
class Foo(Resource):
def get(self):
pass
def post(self):
pass
It's so simple, yet I can't get it to work. I followed, http://flask.pocoo.org/docs/0.10/patterns/packages/, and it works for a regular flask app, but not yet found luck structuring restful extension flask apps, which is what I'm dealing with. Please help guys!