librelist archives

« back to archive

Flask Divisional Blueprint

Flask Divisional Blueprint

From:
john
Date:
2015-01-11 @ 16:01
Hello everyone,

I am trying to learn how to organize a web app into the Divisional
Blueprint pattern as explained on www.exploreflask.com. Being new to Python
and Flask, there are a few things that I am missing.

I currently have something like this.

mywebapp
|
|___ client
|           |___     __init__.py
|           |___    static
|           |___    templates
|           |___    views.py
|
|____ home
           (similar to client layout)|
|
|
|_  __init__.py
|
|_ requirements.txt
|_ Procfile
|_ models.py
|_ runtime.txt


Can anyone point me in the direction of something like a skeleton webapp
layout out like this?

I'm getting a bit lost in the weeds. I've got a folder called, "mywebapp"
do I need to have another package under that called app and all of the
divisions under app or do they belong under "mywebapp".

If someone could point me in the right direction or provide a directory
layout example, I would really appreciate it.

Cheers!
John

Re: [flask] Flask Divisional Blueprint

From:
Brijesh Bittu
Date:
2015-01-11 @ 17:08
Hi John

All the divisions belong in mywebapp.
No need to create another app folder. You could break the models file for
each of the divisions though .

Thanks.
Brijesh
On Jan 11, 2015 9:35 PM, "john" <john.brosan@gmail.com> wrote:

> Hello everyone,
>
> I am trying to learn how to organize a web app into the Divisional
> Blueprint pattern as explained on www.exploreflask.com. Being new to
> Python and Flask, there are a few things that I am missing.
>
> I currently have something like this.
>
> mywebapp
> |
> |___ client
> |           |___     __init__.py
> |           |___    static
> |           |___    templates
> |           |___    views.py
> |
> |____ home
>            (similar to client layout)|
> |
> |
> |_  __init__.py
> |
> |_ requirements.txt
> |_ Procfile
> |_ models.py
> |_ runtime.txt
>
>
> Can anyone point me in the direction of something like a skeleton webapp
> layout out like this?
> < div>
> I'm getting a bit lost in the weeds. I've got a folder called, "mywebapp"
> do I need to have another package under that called app and all of the
> divisions under app or do they belong under "mywebapp".
>
> If someone could point me in the right direction or provide a directory
> layout example, I would really appreciate it.
>
> Cheers!
> John
>

Re: [flask] Flask Divisional Blueprint

From:
john
Date:
2015-01-11 @ 19:26
Hi Brijesh,

Thanks for the information. I suppose the real key piece I am missing here
is how to bootstrap the app. I've got things setup as blue prints and
registered them on the app. I just don't have the experience to know what
my run.py and the mywebapp/__init__.py should look like so I can get down
to developing and have access to all of the views/routes in each blueprint.

Thanks,
John

On Sun, Jan 11, 2015 at 12:08 PM, Brijesh Bittu <brijeshb42@gmail.com>
wrote:

> Hi John
>
> All the divisions belong in mywebapp.
> No need to create another app folder. You could break the models file for
> each of the divisions though .
>
> Thanks.
> Brijesh
> On Jan 11, 2015 9:35 PM, "john" <john.brosan@gmail.com> wrote:
>
>> Hello everyone,
>>
>> I am trying to learn how to organize a web app into the Divisional
>> Blueprint pattern as explained on www.exploreflask.com. Being new to
>> Python and Flask, there are a few things that I am missing.
>>
>> I currently have something like this.
>>
>> mywebapp
>> |
>> |___ client
>> |           |___     __init__.py
>> |           |___    static
>> |           |___    templates
>> |           |___    views.py
>> |
>> |____ home
>>            (similar to client layout)|
>> |
>> |
>> |_  __init__.py
>> |
>> |_ requirements.txt
>> |_ Procfile
>> |_ models.py
>> |_ runtime.txt
>>
>>
>> Can anyone point me in the direction of something like a skeleton webapp
>> layout out like this?
>> < div>
>> I'm getting a bit lost in the weeds. I've got a folder called, "mywebapp"
>> do I need to have another package under that called app and all of the
>> divisions under app or do they belong under "mywebapp".
>>
>> If someone could point me in the right direction or provide a directory
>> layout example, I would really appreciate it.
>>
>> Cheers!
>> John
>>
>

Re: [flask] Flask Divisional Blueprint

From:
john
Date:
2015-01-11 @ 19:33
I'm using the information at this site

https://exploreflask.com/blueprints.html

While the docs here are excellent, I seem to simply be missing something.

Cheers!
John

On Sun, Jan 11, 2015 at 2:26 PM, john <john.brosan@gmail.com> wrote:

> Hi Brijesh,
>
> Thanks for the information. I suppose the real key piece I am missing here
> is how to bootstrap the app. I've got things setup as blue prints and
> registered them on the app. I just don't have the experience to know what
> my run.py and the mywebapp/__init__.py should look like so I can get down
> to developing and have access to all of the views/routes in each blueprint.
>
> Thanks,
> John
>
> On Sun, Jan 11, 2015 at 12:08 PM, Brijesh Bittu <brijeshb42@gmail.com>
> wrote:
>
>> Hi John
>>
>> All the divisions belong in mywebapp.
>> No need to create another app folder. You could break the models file for
>> each of the divisions though .
>>
>> Thanks.
>> Brijesh
>> On Jan 11, 2015 9:35 PM, "john" <john.brosan@gmail.com> wrote:
>>
>>> Hello everyone,
>>>
>>> I am trying to learn how to organize a web app into the Divisional
>>> Blueprint pattern as explained on www.exploreflask.com. Being new to
>>> Python and Flask, there are a few things that I am missing.
>>>
>>> I currently have something like this.
>>>
>>> mywebapp
>>> |
>>> |___ client
>>> |           |___     __init__.py
>>> |           |___    static
>>> |           |___    templates
>>> |           |___    views.py
>>> |
>>> |____ home
>>>            (similar to client layout)|
>>> |
>>> |
>>> |_  __init__.py
>>> |
>>> |_ requirements.txt
>>> |_ Procfile
>>> |_ models.py
>>> |_ runtime.txt
>>>
>>>
>>> Can anyone point me in the direction of something like a skeleton webapp
>>> layout out like this?
>>> < div>
>>> I'm getting a bit lost in the weeds. I've got a folder called,
>>> "mywebapp" do I need to have another package under that called app and all
>>> of the divisions under app or do they belong under "mywebapp".
>>>
>>> If someone could point me in the right direction or provide a directory
>>> layout example, I would really appreciate it.
>>>
>>> Cheers!
>>> John
>>>
>>
>

Re: [flask] Flask Divisional Blueprint

From:
Eric B
Date:
2015-01-11 @ 19:56
This is just one example of how you could restructure the app to be
extendable and bigger than one python file.

mywebapp
|
|___ mywebapp
|          |___ __init__.py
|          |___ models.py
|          |___ client
|                     |___ __init__.py
|          |___ home
|                     |___ __init__.py
|
|___ run.py
|___ requirements.txt
|___ setup.py

mywebapp/mywebapp/__init__.py:
from flask import Flask
from client import client_blueprint
from home import home_blueprint

app = Flask(__name__)
app.register_blueprint(client_blueprint)
app.register_blueprint(home_blueprint)

mywebapp/run.py:
from mywebapp import app
app.run()


On Sun Jan 11 2015 at 2:37:38 PM john <john.brosan@gmail.com> wrote:

> I'm using the information at this site
>
> https://exploreflask.com/blueprints.html
>
> While the docs here are excellent, I seem to simply be missing something.
>
> Cheers!
> John
>
> On Sun, Jan 11, 2015 at 2:26 PM, john <john.brosan@gmail.com> wrote:
>
>> Hi Brijesh,
>>
>> Thanks for the information. I suppose the real key piece I am missing
>> here is how to bootstrap the app. I've got things setup as blue prints and
>> registered them on the app. I just don't have the experience to know what m
>> y run.py and the mywebapp/__init__.py should look like so I can get down to
>> developing and have access to all of the views/routes in each blueprint.
>>
>> Thanks,
>> John
>>
>> On Sun, Jan 11, 2015 at 12:08 PM, Brijesh Bittu <brijeshb42@gmail.com>
>> wrote:
>>
> Hi John
>>>
>>> All the divisions belong in mywebapp.
>>> No need to create another app folder. You could break the models file
>>> for each of the divisions though .
>>>
>>> Thanks.
>>> Brijesh
>>>
>> On Jan 11, 2015 9:35 PM, "john" <john.brosan@gmail.com> wrote:
>>>
>> Hello everyone,
>>>>
>>>> I am trying to learn how to organize a web app into the Divisional
>>>> Blueprint pattern as explained on www.exploreflask.com. Being new to
>>>> Python and Flask, there are a few things that I am missing.
>>>>
>>>> I currently have something like this.
>>>>
>>>> mywebapp
>>>> |
>>>> |___ client
>>>> |           |___     __init__.py
>>>> |           |___    static
>>>> |           |___    templates
>>>> |           |___    views.py
>>>> |
>>>> |____ home
>>>>
>>>            (similar t o client layout)|
>>>>
>>> |
>>>> |
>>>> |_  __init__.py
>>>> |
>>>> |_ requirements.txt
>>>> |_ Procfile
>>>> |_ models.py
>>>> |_ runtime.txt
>>>>
>>>>
>>>> Can anyone point me in the direction of something like a skeleton
>>>> webapp layout out like this?
>>>>
>>> < div>
>>>>
>>> I'm getting a bit lost in the weeds. I've got a folder called,
>>>> "mywebapp" do I need to have another package under that called app and all
>>>> of the divisions under app or do they belong under "mywebapp".
>>>>
>>>> If someone could point me in the right direction or provide a directory
>>>> layout example, I would really appreciate it.
>>>>
>>>> Cheers!
>>>> John
>>>>
>>>

Re: [flask] Flask Divisional Blueprint

From:
john
Date:
2015-01-11 @ 22:28
Hi Eric,

That seems to get the app running. How do I actually get the routes and
views to work in this configuration?  I assume I can still use a base
template that all of the blueprint modules can inherit from? Sorry for so
many questions, but I am just about there.

Thanks!
John

On Sun, Jan 11, 2015 at 2:56 PM, Eric B <neurosnap@gmail.com> wrote:

> This is just one example of how you could restructure the app to be
> extendable and bigger than one python file.
>
> mywebapp
> |
> |___ mywebapp
> |          |___ __init__.py
> |          |___ models.py
> |          |___ client
> |                     |___ __init__.py
> |          |___ home
> |                     |___ __init__.py
> |
> |___ run.py
> |___ requirements.txt
> |___ setup.py
>
> mywebapp/mywebapp/__init__.py:
> from flask import Flask
> from client import client_blueprint
> from home import home_blueprint
>
> app = Flask(__name__)
> app.register_blueprint(client_blueprint)
> app.register_blueprint(home_blueprint)
>
> mywebapp/run.py:
> from mywebapp import app
> app.run()
>
>
> On Sun Jan 11 2015 at 2:37:38 PM john <john.brosan@gmail.com> wrote:
>
>> I'm using the information at this site
>>
>> https://exploreflask.com/blueprints.html
>>
>> While the docs here are excellent, I seem to simply be missing something.
>>
>> Cheers!
>> John
>>
>> On Sun, Jan 11, 2015 at 2:26 PM, john <john.brosan@gmail.com> wrote:
>>
>>> Hi Brijesh,
>>>
>>> Thanks for the information. I suppose the real key piece I am missing
>>> here is how to bootstrap the app. I've got things setup as blue prints and
>>> registered them on the app. I just don't have the experience to know what m
>>> y run.py and the mywebapp/__init__.py should look like so I can get down to
>>> developing and have access to all of the views/routes in each blueprint.
>>>
>>> Thanks,
>>> John
>>>
>>> On Sun, Jan 11, 2015 at 12:08 PM, Brijesh Bittu <brijeshb42@gmail.com>
>>> wrote:
>>>
>> Hi John
>>>>
>>>> All the divisions belong in mywebapp.
>>>> No need to create another app folder. You could break the models file
>>>> for each of the divisions though .
>>>>
>>>> Thanks.
>>>> Brijesh
>>>>
>>> On Jan 11, 2015 9:35 PM, "john" <john.brosan@gmail.com> wrote:
>>>>
>>> Hello everyone,
>>>>>
>>>>> I am trying to learn how to organize a web app into the Divisional
>>>>> Blueprint pattern as explained on www.exploreflask.com. Being new to
>>>>> Python and Flask, there are a few things that I am missing.
>>>>>
>>>>> I currently have something like this.
>>>>>
>>>>> mywebapp
>>>>> |
>>>>> |___ client
>>>>> |           |___     __init__.py
>>>>> |           |___    static
>>>>> |           |___    templates
>>>>> |           |___    views.py
>>>>> |
>>>>> |____ home
>>>>>
>>>>            (similar t o client layout)|
>>>>>
>>>> |
>>>>> |
>>>>> |_  __init__.py
>>>>> |
>>>>> |_ requirements.txt
>>>>> |_ Procfile
>>>>> |_ models.py
>>>>> |_ runtime.txt
>>>>>
>>>>>
>>>>> Can anyone point me in the direction of something like a skeleton
>>>>> webapp layout out like this?
>>>>>
>>>> < div>
>>>>>
>>>> I'm getting a bit lost in the weeds. I've got a folder called,
>>>>> "mywebapp" do I need to have another package under that called app and all
>>>>> of the divisions under app or do they belong under "mywebapp".
>>>>>
>>>>> If someone could point me in the right direction or provide a
>>>>> directory layout example, I would really appreciate it.
>>>>>
>>>>> Cheers!
>>>>> John
>>>>>
>>>>

Re: [flask] Flask Divisional Blueprint

From:
john
Date:
2015-01-12 @ 02:54
Ok, I think I got it!

I have a blueprint called, "home" and the __init__.py contained the
following:

from flask import Blueprint

home = Blueprint(
    'home',
    __name__,
    template_folder='templates',
    static_folder='static'
)


With just this, I was getting a 404. I had to import the views for the
blueprint with the following line.

from . import views

Thanks!


On Sun, Jan 11, 2015 at 5:28 PM, john <john.brosan@gmail.com> wrote:

> Hi Eric,
>
> That seems to get the app running. How do I actually get the routes and
> views to work in this configuration?  I assume I can still use a base
> template that all of the blueprint modules can inherit from? Sorry for so
> many questions, but I am just about there.
>
> Thanks!
> John
>
> On Sun, Jan 11, 2015 at 2:56 PM, Eric B <neurosnap@gmail.com> wrote:
>
>> This is just one example of how you could restructure the app to be
>> extendable and bigger than one python file.
>>
>> mywebapp
>> |
>> |___ mywebapp
>> |          |___ __init__.py
>> |          |___ models.py
>> |          |___ client
>> |                     |___ __init__.py
>> |          |___ home
>> |                     |___ __init__.py
>> |
>> |___ run.py
>> |___ requirements.txt
>> |___ setup.py
>>
>> mywebapp/mywebapp/__init__.py:
>> from flask import Flask
>> from client import client_blueprint
>> from home import home_blueprint
>>
>> app = Flask(__name__)
>> app.register_blueprint(client_blueprint)
>> app.register_blueprint(home_blueprint)
>>
>> mywebapp/run.py:
>> from mywebapp import app
>> app.run()
>>
>>
>> On Sun Jan 11 2015 at 2:37:38 PM john <john.brosan@gmail.com> wrote:
>>
>>> I'm using the information at this site
>>>
>>> https://exploreflask.com/blueprints.html
>>>
>>> While the docs here are excellent, I seem to simply be missing something.
>>>
>>> Cheers!
>>> John
>>>
>>> On Sun, Jan 11, 2015 at 2:26 PM, john <john.brosan@gmail.com> wrote:
>>>
>>>> Hi Brijesh,
>>>>
>>>> Thanks for the information. I suppose the real key piece I am missing
>>>> here is how to bootstrap the app. I've got things setup as blue prints and
>>>> registered them on the app. I just don't have the experience to know what m
>>>> y run.py and the mywebapp/__init__.py should look like so I can get down to
>>>> developing and have access to all of the views/routes in each blueprint.
>>>>
>>>> Thanks,
>>>> John
>>>>
>>>> On Sun, Jan 11, 2015 at 12:08 PM, Brijesh Bittu <brijeshb42@gmail.com>
>>>> wrote:
>>>>
>>> Hi John
>>>>>
>>>>> All the divisions belong in mywebapp.
>>>>> No need to create another app folder. You could break the models file
>>>>> for each of the divisions though .
>>>>>
>>>>> Thanks.
>>>>> Brijesh
>>>>>
>>>> On Jan 11, 2015 9:35 PM, "john" <john.brosan@gmail.com> wrote:
>>>>>
>>>> Hello everyone,
>>>>>>
>>>>>> I am trying to learn how to organize a web app into the Divisional
>>>>>> Blueprint pattern as explained on www.exploreflask.com. Being new to
>>>>>> Python and Flask, there are a few things that I am missing.
>>>>>>
>>>>>> I currently have something like this.
>>>>>>
>>>>>> mywebapp
>>>>>> |
>>>>>> |___ client
>>>>>> |           |___     __init__.py
>>>>>> |           |___    static
>>>>>> |           |___    templates
>>>>>> |           |___    views.py
>>>>>> |
>>>>>> |____ home
>>>>>>
>>>>>            (similar t o client layout)|
>>>>>>
>>>>> |
>>>>>> |
>>>>>> |_  __init__.py
>>>>>> |
>>>>>> |_ requirements.txt
>>>>>> |_ Procfile
>>>>>> |_ models.py
>>>>>> |_ runtime.txt
>>>>>>
>>>>>>
>>>>>> Can anyone point me in the direction of something like a skeleton
>>>>>> webapp layout out like this?
>>>>>>
>>>>> < div>
>>>>>>
>>>>> I'm getting a bit lost in the weeds. I've got a folder called,
>>>>>> "mywebapp" do I need to have another package under that called app and all
>>>>>> of the divisions under app or do they belong under "mywebapp".
>>>>>>
>>>>>> If someone could point me in the right direction or provide a
>>>>>> directory layout example, I would really appreciate it.
>>>>>>
>>>>>> Cheers!
>>>>>> John
>>>>>>
>>>>>
>

Re: [flask] Flask Divisional Blueprint

From:
Brijesh Bittu
Date:
2015-01-12 @ 05:13
Hi John,

I was wrong before. You do need to create another app folder inside the
main webapp.
Here is a bootstrapped app code that I am currently working on. You can
take a look to get the idea how to get started.

https://github.com/brijeshb42/flask-web

Thanks.
Brijesh

On Mon, Jan 12, 2015 at 8:24 AM, john <john.brosan@gmail.com> wrote:

> Ok, I think I got it!
>
> I have a blueprint called, "home" and the __init__.py contained the
> following:
>
> from flask import Blueprint
>
> home = Blueprint(
>     'home',
>     __name__,
>     template_folder='templates',
>     static_folder='static'
> )
>
>
> Wi
>  th just this, I was getting a 404. I had to import the views for the 
blueprint with the following line.
>
> from . import views
>
> Thanks!
>
>
> On Sun, Jan 11, 2015 at 5:28 PM, john <john.brosan@gmail.com> wrote:
>
>> Hi Eric,
>>
>> That seems to get the app running. How do I actually get the routes and
>> views to work in this configuration?  I assume I can still use a bas e
>> template that all of the blueprint modules can inherit from? Sorry for so
>> many questions, but I am just about there.
>>
>> Thanks!
>> John
>>
>> On Sun, Jan 11, 2015 at 2:56 PM, Eric B <neurosnap@gmail.com> wrote:
>>
>>> This is just one example of how you could restructure the app to be
>>> extendable and bigger than one python file.
>>>
>>> mywebapp
>>> |
>>> |___ mywebapp
>>> |          |___ __init__.py
>>> |          |___ models.py
>>> |          |___ client
>>> |                     |___ __init__.py
>>> |          |___ home
>>> |       Â               |___ __init__.py
>>> |
>>> |___ run.py
>>> |___ requirements.txt
>>> |___ setup.py
>>>
>>> mywebapp/mywebapp/__init__.py:
>>> from flask import Flask
>>> from client import client_blueprint
>>> from home import home_blueprint
>>>
>>> app = Flask(__name__)
>>> app.register_blueprint(client_blueprint)
>>> app.register_blueprint(home_blueprint)
>>>
>>> mywebapp/run.py:
>>> from mywebapp import app
>>> app.run()
>>>
>>>
>>> On Sun Jan 11 2015 at 2:37:38 PM john <john.brosan@gmail.com> wrote:
>>>
>>>> I'm using the information at this site
>>>>
>>>> https://explorefl ask.com/blueprints.html
>>>> <https://exploreflask.com/blueprints.html>
>>>>
>>>> While the docs here are excellent, I seem to simply be missing
>>>> something.
>>>>
>>>> Cheers!
>>>> John
>>>>
>>>> On Sun, Jan 11, 2015 at 2:26 PM, john <john.brosan@gmail.com> wrote:
>>>>
>>>>> Hi Brijesh,
>>>>>
>>>>> Thanks for the information. I suppose the real key piece I am missing
>>>>> here is how to bootstrap the app. I've got things setup as blue prints and
>>>>> registered them on the app. I just don't have the experience to know what m
>>>>> y run.py and the mywebapp/__init__.py should look like so I can get down to
>>>>> developing and have access to all of the views/routes in each blueprint.
>>>>>
>>>>> Thanks,
>>>>> John
>>>>>
>>>>> On Sun, Jan 11, 2015 at 12:08 PM, Brijesh Bittu <brijeshb42@gmail.com>
>>>>> wrote:
>>>>>
>>>> Hi John
>>>>>
>>>>> All the divisions belong in mywebapp.
>>>>> No need to create another app folder. You could break the models file
>>>>> for each of the divisions though .
>>>>>
>>>>> Thanks.
>>>>> Brijesh
>>>>>
>>>>> On Jan 11, 2015 9:35 PM, "john" <john.brosan@gmail.com> wrote:
>>>>>>
>>>>> Hello everyone,
>>>>>>>
>>>>>>> I am trying to learn how to organize a web app into the Divisional
>>>>>>> Blueprint pattern as explained on www.exploreflask.com. Being new
>>>>>>> to Python and Flask, there are a few things that I am missing.
>>>>>>>
>>>>>>> I currently have something like this.
>>>>>>>
>>>>>>> mywebapp
>>>>>>> |
>>>>>>> |___ client
>>>>>>> |           |___     __init__.py
>>>>>>> |           |___    static
>>>>>>> |           |___    templates
>>>>>>> |           |___    views.py
>>>>>>> |
>>>>>>> |____ home
>>>>>>>
>>>>>>            (similar t o client layout)|
>>>>>>>
>>>>>> |
>>>>>>> |
>>>>>>> |_  __init__.py
>>>>>>> |
>>>>>>> |_ requirements.txt
>>>>>>> |_ Procfile
>>>>>>> |_ models.py
>>>>>>> |_ runtime.txt
>>>>>>>
>>>>>>>
>>>>>>> Can anyone point me in the direction of something like a skeleton
>>>>>>> webapp layout out like this?
>>>>>>>
>>>>>> < div>
>>>>>>>
>>>>>> I'm getting a bit lost in the weeds. I've got a folder called,
>>>>>>> "mywebapp" do I need to have another package under that called app and all
>>>>>>> of the divisions under app or do they belong under "mywebapp".
>>>>>>>
>>>>>>> If someone could point me in the right direction or provide a
>>>>>>> directory layout example, I would really appreciate it.
>>>>>>>
>>>>>>> Cheers!
>>>>>>> John
>>>>>>>
>>>>>>
>>
>