Relative import of a apackage in python flask application

198 views Asked by At

Trying to make the sample flask application more modular,I am new to python and flask trying to build a sample application where , I have planned to maintain the folder structure of the application as shown belowenter image description here

where the description of the package are as fallows

config ---> database configuration details flaskApp 1 model--->which has the mongodb schema 2 viewController----> the endpoint to be accessed

static---> which contains the single html page which i just need to serve (not render it)

The code repo for the same is in github https://github.com/dhanalakshmiZendynamix/python-Flask-relative-module.git

I am facing following problems 1: I am not finding a easy way to access the packages to another packages as in folder structure(ie, models inside viewController where the end points are present)

2:Not sure how to serve the html page inside static folder

Tried reading many source https://exploreflask.com/en/latest/preface.html http://pyvideo.org/pycon-us-2014/writing-restful-web-services-with-flask.html

But still not sure how to get it working

Please help to adopt to the above folder structure and access to the end point really not sure how to go about it

Any suggestion and pointer would help a lot Thank you

1

There are 1 answers

1
Stijn Diependaele On

@dhana lakshmi Check the registered url endpoints in your app. Start Python on the commandline in your project directory and execute the following commands:

>>> import flaskApp 
>>> app = flaskApp.create_app() 
>>> app.url_map 

Please add the output to your question

And I really think you need to read up a bit on python and flask first, here is a list with some great resources on flask https://github.com/humiaozuzu/awesome-flask