I have this app.yaml file:
application: *****
version: 1
runtime: python
api_version: 1
handlers:
- url: /static
static_dir: static
- url: /.*
script: main.py
builtins:
- datastore_admin: on
And this main.py script:
import service
...
...
class UrlHandler(webapp.RequestHandler):
def get(self):
if self.request.query_string != '':
service.MainPage()
else:
self.response.out.write(template.render('templates/main.html', {}))
...
...
Is it possible to do what I am trying to do? I want …mainpage/ requests to land on the main html page with a css style sheet and …mainpage/?… requests to be handled by the MainPage class in service called from main.py.
service.MainPage()isn’t going to have access to therequestandresponseobjects that the framework has stuck on to thewebapp.RequestHandlerinstance thatget()sees.You could pass
selftoservice.MainPage()(assuming that’s a function, and not a class that you’re creating an instance of and them doing nothing with).Or, even simpler, (and assuming that
MainPageis awebapp.RequestHandlersubclass), move the ‘render templates/main.html on no query string’ logic there, since it’s only a few lines.