Hi basic question,
Basically I'm having trouble modularizing handlers in GAE.
Specifically in my application I have a download button that calls a Test handler so far I have:
<script>
$('#download').button().click(function(){
$('<iframe id="dlBox" name="dlBox" hieght=0px width=0px src="/test">').appendTo('body');
});
</script>
And then at the bottom of the code I have :
class Test(webapp2.RequestHandler):
def get(self):
logging.info("Entered Handler")
self.response.headers['Content-Type'] = 'text/csv'
self.response.headers['Content-Disposition'] = "attachment; filename=fname.csv"
self.response.out.write(','.join(['a', 'cool', 'test']))
application = webapp2.WSGIApplication([('/', MainHandler),
('/query', QueryHandler),
('/test', Test) ],
debug=True)
And this works but I want to be able to make the Test class into its own .py file.
So I made a folder called handlers saved the class as test.py and then changed my app.yaml to include:
- url: /test
script: handlers/test.py
However when I try clicking the download button it gives the error : ImportError('Could not find module %s' % fullname)
ImportError: Could not find module handlers.test
I have also tried changing the app.yaml to:
- url: /handlers
static_dir: handlers
and changing the source in the javascript code to src="/handlers/test.py" but in this case there's no error but also it doesn't enter the handler at all it simply just says "GET /handlers/test.py HTTP/1.1" 200 -
What am I missing?
Thanks!