0

The following code comes from here. How am I supposed to see the results? Can I use the GAE interactive console somehow, or do I need to create a whole app with an app.yaml etc and run it in the gae launcher? I am particularly interested in snippets with html.

import datetime

from google.appengine.ext import webapp

class MyRequestHandler(webapp.RequestHandler):
    def get(self):
        self.response.out.write("<html><body>")
        self.response.out.write("<p>Welcome to the Internet!</p>")
        self.response.out.write("</body></html>")

        expires_date = datetime.datetime.utcnow() + datetime.timedelta(365)
        expires_str = expires_date.strftime("%d %b %Y %H:%M:%S GMT")
        self.response.headers.add_header("Expires", expires_str)

2 Answers 2

1

You're supposed to run it in the development server. You see the results in your browser.

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

5 Comments

Ok, I did as you suggested. Now can you tell me what the last line in the example code does because I don't see it in the html output(self.response.headers.add_header("Expires", expires_str))?
Seems to be adding an Expires header to the HTTP response to tell the browser how long to cache it for.
I assumed anything like that would have to show in the raw page output, but all I see is the following. <html><body><p>Welcome to the Internet!</p></body></html> A puzzle to me.
Get chrome and press Crtl shift and i and you will get a console that will allow you to inspect the header s of that page, which is where the info is, not in the web page itself. developers.google.com/chrome-developer-tools/docs/…
Paul, Thanks for that link etc. On my Mac I use Cmd Option I (and btw, Cmd Shift I seems to create an email message of the html page). I still cannot locate that Expires header business in the developer console. But there is such a wealth of info there. I guess I need to find a video or some docs to use those developer tools better.
0

Have you installed the development appserver?

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.