Multiple WSGI apps

6 views
Skip to first unread message

arnie

unread,
Jan 12, 2009, 9:02:36 AM1/12/09
to Google App Engine
Hi all
Using Google App Engine SDK with default port setting of 8080. I have
two WSGI applications [App1 and App2 both are web services with no UI
related code in them]. App1 is running on default port 8080. Can dev
server listens for multiple web applications on same port? If no, then
what other ports can be used?
Also these two apps need to access two tables [1 To Many
relationship], when we go to deploy these apps on GAE do I need
seperate application ID for these two apps [I think:YES but google
DOCS says per mobile phone # there is only one app ID]?
Can these two applications be able to access the common data model or
do I need to do some special coding for this?
Thanks from a GAE fresher
arnie

djidjadji

unread,
Jan 12, 2009, 9:36:38 AM1/12/09
to google-a...@googlegroups.com
Why not select the two different Apps with your app.yaml file
------------------------
- url: /app1/.*
script: App1.py

- url: /app2/.*
script: App2.py
------------------------

Or you can put both handlers in one py file and select the one you need with

class App1Handler(webapp.RequestHandler):
def get(self,todo):
pass
....
application = webapp.WSGIApplication(
[('/app1/(.*)', App1Handler),
('/app2/(.*)', App2Handler),
],
debug=False)

If they need to use the same data then they must be uploaded under 1 app ID.
You have one administrator per mobile phone, and an administrator can
have 10 application IDs.

2009/1/12 arnie <parv...@rediffmail.com>:

arnie

unread,
Jan 13, 2009, 8:36:11 AM1/13/09
to Google App Engine
I have tried doing
- url: /app1/.*
script: App1.py

- url: /app2/.*
script: App2.py
but it is not working. Also what about the other parameters in the
yaml file
application: appname
version: 1
runtime: python
api_version: 1
Will these not be included in in above case?
Thanks

djidjadji

unread,
Jan 13, 2009, 3:29:07 PM1/13/09
to google-a...@googlegroups.com
Yes, I only gave you some of the handlers of the app.yaml file.
How do you get an app working without the header in app.yaml?
When you put in the correct header does it work what you want?

2009/1/13 arnie <parv...@rediffmail.com>:

Ian Bicking

unread,
Jan 14, 2009, 3:08:40 PM1/14/09
to google-a...@googlegroups.com

One way of handling this is to create a dispatcher.  Let's say you have two apps, and you want App1 to show up at / and App2 at /blog, you could do:

def dispatch_app(environ, start_response):
    if environ['PATH_INFO'].startswith('/blog/'):
        environ['SCRIPT_NAME'] += '/blog'
        environ['PATH_INFO'] = environ['PATH_INFO'][5:]
        return App2(environ, start_response)
    return App1(environ, start_response)

Then dispatch_app is the WSGI application you are going to actually serve.  Obviously you can abstract out this dispatch code (for an example: http://svn.pythonpaste.org/Paste/trunk/paste/urlmap.py).

This internal dispatching means all tables are shared.

--
Ian Bicking  |  http://blog.ianbicking.org
Reply all
Reply to author
Forward
0 new messages