1

UPDATED: Changed to simpler python script

I have a website hosted in Google App Engine which is mostly static. Now I have a python script that would return a list of files under a specific folder in the server. I need this list of files in JavaScript.

helloworld.py

import webapp2

class MainPage(webapp2.RequestHandler):
    def get(self):
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.write('Hello, webapp2 World!')
app = webapp2.WSGIApplication([('/GetImages', MainPage)], debug=True)

I am calling this Python script in a <script> tag in my index.html using jQuery

$.ajax({
    type: "GET",
    url: "/GetImages",
    dataType: "text",
    success: function(data) {
        alert(data);
    }
});

In my app.yaml I have this handler defined and also other handlers for static files

- url: /GetImages
  script: helloworld.app

I have started Google App Engine launcher, and when I open my site in localhost:8080/GetImages, I don't see the hello world string.

I think the problem is with my app.yaml. If I add below in the handlers, I get server error. Is this not allowed?

- url: /static
  static_dir: static
8
  • Accessing localhost:8080/GetImages with your browser should show you the result of the request. Commented Nov 25, 2012 at 22:04
  • @leo That gives me a server error. HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request. Commented Nov 25, 2012 at 22:08
  • If you can't access /GetImages, chances are good your javascript can't either. You'll need to figure out why that URL isn't working and then you can proceed down the line of debugging your JS. Commented Nov 25, 2012 at 22:10
  • maybe someone can help me with whatever the problem is with my setup? Commented Nov 25, 2012 at 22:14
  • Are you sure it's your setup? Try returning a simple message and see if it works. If it does, then chances are your function is wrong (..\images doesn't exist, for example). BTW: are you sure ..\images is the way to reference the images folder??? Why BACKSLASH? Commented Nov 25, 2012 at 22:28

1 Answer 1

0

Fixed it. The problem was some incorrect indent in the python script. Stupid mistake :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.