How do I set the application that shows at domain root? Plus a couple other questions...

42 views
Skip to first unread message

Bruce Whealton

unread,
Jul 14, 2017, 1:12:55 PM7/14/17
to web2py-users
Hello all,
              I am having trouble finding information about how to setup what will show when a user comes to my domain, which is being served by web2py.
Currently, I know how to create applications from a single install.   I understand routing or redirects within an app.  However, I cannot find in the code
where the setting exists that says that the welcome application should be displayed.  While I could take the welcome app and just customize it.  However,
I'm very curious as to how web2py knows to display just that specific application out of the box.  I found some route.example.py files within the apps.
However, that means that somewhere web2py needs to be configured to start with the welcome app.
How does one specify that when coming to example.com use myapp when a visitor comes to my domain?  
Do I just use a server redirect ( e.g. using apache2 configure a redirect to .../myapp/c/v)

Since web2py can serve several different applications from one instance or installation of web2py is there a way to have a menu of all the different applications?
For example, myapp1, myapp2, etc. would be displayed somehow at the top of each page in each app.  How would that be done?

Lastly, I was looking at the different directories in each application and was unsure what the difference is between the Modules folder and Plugins?
Also, there are appliances which I like but I ended up discovering more than one appliance that I had found with features for a single application.
So, I was wondering if it was possible to have one app that included for example the Semantic Web appliance with an e-commerce app.
Is there a way to do that, to merge two apps into one?

Thanks,
Bruce  

Leonel Câmara

unread,
Jul 14, 2017, 1:45:29 PM7/14/17
to web2py-users
In regard to routing and setting up an application to be the one that will be shown when people go to your domain

1. Copy exampl/routes.parametric.example.py to web2pyfolder/routes.py
2. edit routes.py

change:
default_application='welcome'
to
default_application='your default application'


Anthony

unread,
Jul 14, 2017, 1:52:05 PM7/14/17
to web...@googlegroups.com
On Friday, July 14, 2017 at 1:12:55 PM UTC-4, Bruce Whealton wrote:
Hello all,
              I am having trouble finding information about how to setup what will show when a user comes to my domain, which is being served by web2py.
Currently, I know how to create applications from a single install.   I understand routing or redirects within an app.  However, I cannot find in the code
where the setting exists that says that the welcome application should be displayed.  While I could take the welcome app and just customize it.  However,
I'm very curious as to how web2py knows to display just that specific application out of the box.  I found some route.example.py files within the apps.
However, that means that somewhere web2py needs to be configured to start with the welcome app.
How does one specify that when coming to example.com use myapp when a visitor comes to my domain?  
Do I just use a server redirect ( e.g. using apache2 configure a redirect to .../myapp/c/v)

See http://web2py.com/books/default/chapter/29/04/the-core#Dispatching and http://web2py.com/books/default/chapter/29/04/the-core#Parameter-based-system.

If no app is specified, web2py looks for an app called "init", and if not found, it then looks for one called "welcome". But there is no need for you to simply customize the welcome app. Name the app whatever you like and use the parameter-based router system to specify a default application -- that application name will then be removed from all URLs.
 
Since web2py can serve several different applications from one instance or installation of web2py is there a way to have a menu of all the different applications?
For example, myapp1, myapp2, etc. would be displayed somehow at the top of each page in each app.  How would that be done?

There is nothing built-in for that -- you would simply have to code some kind of helper function to generate the menu and include it in the layout of each app.

Lastly, I was looking at the different directories in each application and was unsure what the difference is between the Modules folder and Plugins?

Modules are just a place you can put standard Python modules that are specific to your app. Plugins are described here: http://web2py.com/books/default/chapter/29/12/components-and-plugins#Plugins.
 
Also, there are appliances which I like but I ended up discovering more than one appliance that I had found with features for a single application.
So, I was wondering if it was possible to have one app that included for example the Semantic Web appliance with an e-commerce app.
Is there a way to do that, to merge two apps into one?

There is no simple or automated way. You would simply have to combine the files/code of each app into a single app, making any necessary adjustments.

Anthony

Bruce Whealton

unread,
Jul 14, 2017, 5:30:28 PM7/14/17
to web2py-users
Thanks.  I was actually just discovering this from both the Web2py Cookbook book and from the manual/book version 5 available for dl as PDF. :-)
I am curious that this manual has in the path name, /chapter/29/ 
as if it was part of a larger book.

Jim S

unread,
Jul 14, 2017, 5:44:31 PM7/14/17
to web2py-users
Have you not seen this?   http://web2py.com/book

-Jim

Bruce Whealton

unread,
Jul 14, 2017, 5:47:13 PM7/14/17
to web2py-users


On Friday, July 14, 2017 at 1:52:05 PM UTC-4, Anthony wrote:
See http://web2py.com/books/default/chapter/29/04/the-core#Dispatching and http://web2py.com/books/default/chapter/29/04/the-core#Parameter-based-system.

If no app is specified, web2py looks for an app called "init", and if not found, it then looks for one called "welcome". But there is no need for you to simply customize the welcome app. Name the app whatever you like and use the parameter-based router system to specify a default application -- that application name will then be removed from all URLs.

Referring to what Leonel Câmara wrote above, I believe I have to copy the routes.example.py from the default app into the top level web2py folder before this will work.  Due to the fact that I had not put a routes.py file in the top level folder, there must be a part of web2py that says if no app is specified, then look for init app followed by welcome app.  
 
Since web2py can serve several different applications from one instance or installation of web2py is there a way to have a menu of all the different applications?
For example, myapp1, myapp2, etc. would be displayed somehow at the top of each page in each app.  How would that be done?

There is nothing built-in for that -- you would simply have to code some kind of helper function to generate the menu and include it in the layout of each app.

Lastly, I was looking at the different directories in each application and was unsure what the difference is between the Modules folder and Plugins?

Modules are just a place you can put standard Python modules that are specific to your app. Plugins are described here: http://web2py.com/books/default/chapter/29/12/components-and-plugins#Plugins.
Do I use pip install or the conda command?  I don't think so because that does not (easily) give us control over where the module is placed.  So, I assume I download a module from pypi and put it there.
 
 
Also, there are appliances which I like but I ended up discovering more than one appliance that I had found with features for a single application.
So, I was wondering if it was possible to have one app that included for example the Semantic Web appliance with an e-commerce app.
Is there a way to do that, to merge two apps into one?

There is no simple or automated way. You would simply have to combine the files/code of each app into a single app, making any necessary adjustments.

Ok, thanks for the help,
Bruce 

Anthony
Reply all
Reply to author
Forward
0 new messages