JonathanI am currently using that as my base for getting this working. Here is what I have so far:routers = dict(# base routerBASE=dict(domains = {"www.website1.com":"mustangs","www.website2.com":"icysa", }))But, anytime I to either URL, I get the web2py welcome app.Also, I've saved the file as routes.py.
-Jim
On Monday, February 11, 2013 6:32:41 PM UTC-6, Jonathan Lundell wrote:On 11 Feb 2013, at 3:36 PM, Jim S <j...@qlf.com> wrote:I'm trying to route traffic that comes in on a specific URL to a specifc app.Example:www.host1.com should route to the welcome appwww.host2.com should route to mySpecific appI realize this is probably trivial, but I'm really struggling with it. Hoping to do it with routes.py and not through wsgi stuff. Please feel free to set me straight if that is not advisable.Look at the domain-routing provision in the parametric router. Documentation in the book, and in router.example.py.
--
--
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Sorry for being slow at this, route configuration is certainly not a forte of mine. Is there something special I need to do to turn on logging? How would I examine request.env? I'm running all of this from pythonanywhere and don't really know where to find these things.
-Jim
On Mon, Feb 11, 2013 at 9:06
Jonathan
I am currently using that as my base for getting this working. Here is what I have so far:routers = dict(# base routerBASE=dict(domains = {"www.website1.com":"mustangs","www.website2.com":"icysa", }))But, anytime I to either URL, I get the web2py welcome app.Also, I've saved the file as routes.py.
And restarted, right?Try turning on logging for routes and see what you get. You might also examine request.env, and make sure that the target domain is showing up properly.-Jim
On Monday, February 11, 2013 6:32:41 PM UTC-6, Jonathan Lundell wrote:On 11 Feb 2013, at 3:36 PM, Jim S <j...@qlf.com> wrote:I'm trying to route traffic that comes in on a specific URL to a specifc app.Example:www.host1.com should route to the welcome appwww.host2.com should route to mySpecific appI realize this is probably trivial, but I'm really struggling with it. Hoping to do it with routes.py and not through wsgi stuff. Please feel free to set me straight if that is not advisable.Look at the domain-routing provision in the parametric router. Documentation in the book, and in router.example.py.--
--
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe@googlegroups.com.
Sorry for being slow at this, route configuration is certainly not a forte of mine. Is there something special I need to do to turn on logging? How would I examine request.env? I'm running all of this from pythonanywhere and don't really know where to find these things.
Looking at request.env I'm seeing the following:http_host = myaccountname.pythonanywhere.comhttp_referer = http://www.myappurl.comI'm routing in my routes.py based on www.myappurl.com but it never goes there. It is always going to myaccountname.pythonanywhere.com.
--
Hi there,
PythonAnywhere developer here. I assume that the request environment where Jim S was seeing the incorrect http_host is the underlying WSGI environment -- is that correct? If so, that's a weird result. We definitely don't do anything strange and hacky with those headers; I just ran a test app to confirm and it was set to the correct domain -- that is, I saw the correct http_host, and the http_referer was unset.
Jim, perhaps you could point me at the app that had that error? Is there any chance that you'd set up a non-CNAME redirect at your DNS provider? I know that Joker (our one) offers not just CNAMEs but "Web-redirects", which just does an HTTP redirect to the name you provide. Perhaps your provider confuses the two in their interface?
Just for clarity: the link through to the username.pythonanywhere.com domain works purely at the DNS level. We need to be able to move web apps from IP address to IP address for load balancing, so we ask our customers to set up their domain with a CNAME to username.pythonanywhere.com with their DNS provider. But that's just a DNS thing; by the time a request from a browser gets to our servers, it's just to a specific IP address, with the appropriate Host: header in the HTTP request.
There should definitely be no weird redirects going on; requests are routed to the appropriate WSGI app based entirely on the hostname provided in the HTTP request, and while that routing knows about which user's sandbox the request should be routed to, it knows nothing about the username.pythonanywhere.com domain.
All the best,
Giles
I am facing a similar problem. I use vps.com for DNS server and I do not see a way to redirect the top domain.BTW. I am also using pythonanywhere (planning to move web2py there) and I noticed I had to visit:https://<username>.pythonanywhere.com/admin/default/reload_routesto reload the routes. Clicking on [reload app] did not do it for me.
#!/usr/bin/python# -*- coding: utf-8 -*-routers = dict( # base router BASE=dict( default_application='engagementsquared', domains={'www.engagementsquared.com':'engagementsquared'} ),)--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/2aAx3-6EOq8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
#!/usr/bin/python# -*- codingf-8 -*-routers = dict( # base router BASE=dict( default_application='engagementsquared', domains={'www.engagementsquared.com':'engagementsquared'} ),)import osimport sys
# add your project directory to the sys.pathproject_home = u'/home/alexglaros/web2py/'if project_home not in sys.path: sys.path = [project_home] + sys.path
sys.stdout = sys.stderros.chdir(project_home)
# serve web2py via WSGI handlerfrom gluon.main import wsgibase as applicationit is working. Pythonanywhere.com folks were really helpful.There was so much trial and error I don't which of the below processes was responsible for success and what might be inefficient.Put routes.py under web2py main directory: / > home > alexglaros > web2py > routes.py NOT UNDER YOUR SPECIFIC APP LIKE THIS: / > home > alexglaros > web2py > applications > engagementsquared > routes.py
#!/usr/bin/python# -*- codingf-8 -*-routers = dict(# base routerBASE=dict(default_application='engagementsquared',domains={'www.engagementsquared.com':'engagementsquared'}),)
create this file according to their website directions: WSGI configuration file:
import osimport sys# add your project directory to the sys.pathproject_home = u'/home/alexglaros/web2py/'if project_home not in sys.path:sys.path = [project_home] + sys.pathsys.stdout = sys.stderros.chdir(project_home)# serve web2py via WSGI handlerfrom gluon.main import wsgibase as application
At hostmonster.com, here is advice from pythonanywhere.com support: PythonAnywhere web apps for specific domains. If you go to www.engagementsquared.com, you'll see a PythonAnywhere "coming soon" page. This means that you've set up the CNAME for www.engagementsquared.com correctly -- the HTTP redirect problem is only with the version without the www. But you only have a web up set up on PythonAnywhere for alexglaros.pythonanywhere.com. This page explains how to set things up so that you can serve an existing web app on a new domain: <https://www.pythonanywhere.com/wiki/UsingANewDomainForExistingWebApp>Did above,then back at pythonanywhere.com site was careful to choose "manual configuration", not "create a new Web2py app". Easy to miss that. So even though I had an app running, I still had to choose "Add a new app".Finally, hit the "reload app" button and instant success. Both stripped URL "engagementsquared.com" and with a "www" www.engagmentsquared.com work.Alex