Note that there are some explanatory texts on larger screens.

plurals
  1. POwebapp2 DomainRoute is not matching
    primarykey
    data
    text
    <p>I'm trying to launch a webserver serving several sites under several subdomains. I'm using Pythen with webapp2 and paste. My Server is behind a router that asigns a static IP adress to the server and forwards port 80. The router itself has no static IP adress assigned by my ISP so I'm using DDNS (lets say example.dlinkddns.com) . In my folder hierarchy each folder represents a subdomain and is a python module.</p> <p>Like this:</p> <pre><code>server/app.py server/www server/www/__init__.py server/test server/test/__init__.py </code></pre> <p>they should be reachable via www.mydomain.com and test.mydomain.com I set *.mydomain.com to be a CNAME for example.dlinkddns.com</p> <p>This is server/app.py:</p> <pre class="lang-python prettyprint-override"><code>import sys import os import webapp2 from webapp2_extras import routes from paste import httpserver DOMAIN = 'mydomain.com' class Fallback(webapp2.RequestHandler): def get(self, *args, **kw): self.response.write('Fallback...\n'+str(args)+'\n'+str(kw)) def main(): dirs = [name for name in os.listdir(".") if os.path.isdir(name)] dirs.remove('env') # folder created by package virtualenv - needed for paste rs = [] for subdomain in dirs: # import subdomain package exec('import '+subdomain) # add routes defined for subdomain exec('rs += [routes.DomainRoute("'+subdomain+'.'+DOMAIN+'", '+subdomain+'.routes)]') rs += [routes.DomainRoute("&lt;domain:.*&gt;",[webapp2.Route('/&lt;:.*&gt;',Fallback,name='fallback')])] app = webapp2.WSGIApplication(rs) httpserver.serve(app, host='0.0.0.0', port='80') if __name__ == '__main__': main() </code></pre> <p>And this is how my www package looks like:</p> <pre class="lang-python prettyprint-override"><code>__init__.py import webapp2 class MainMain(webapp2.RequestHandler): def get(self,target): self.response.write('Hello, webapp2! www.mydomain.com at:'+target) routes = [ webapp2.Route('/&lt;target&gt;', handler=MainMain, name='main-main') ] </code></pre> <p>The problem now is, when I visit www.mydomain.com the fallback handler seems to match but MainMain handler should. The output is </p> <pre><code>Fallback... () {'domain':'0.0.0.0'}. </code></pre> <p>It looks like my app wouldn't recognize the domains at all. Same thing happens when I visit example.dlinkddns.com. I also tried it without the fallback handler but then it only showed me the 404 page for every route and every domain...</p> <p>I also tried to start the server with</p> <pre><code>httpserver.serve(app, host='192.168.178.33', port='80') </code></pre> <p>This is the static assigned IP address of my server in my LAN. The the output changes to</p> <pre><code>Fallback... () {'domain':'192.168.178.33'}. </code></pre> <p>What am I doing wrong? Thanks for any help!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload