Andres Riofrio
Andres Riofrio

Reputation: 10347

How can I use webapp2 in Google App Engine using Python 2.5?

I want to use webapp2, which is the default for Python 2.7, under Python 2.5. Is this possible? How?

Upvotes: 1

Views: 281

Answers (2)

coto
coto

Reputation: 2325

yes, webapp2 is part of Python 2.7.

A very good way to use that library with python 2.7 is in this App engine Boilerplate https://github.com/coto/gae-boilerplate

Upvotes: 0

systempuntoout
systempuntoout

Reputation: 74064

Webapp2 is part of the Python 2.7 runtime but it's also a library compatible with Python 2.5 that you can download and use in your project like many other libraries.
Indeed, as noted in the documentation, Webapp2 can be used outside of GAE independently of the App Engine SDK.

To use it in your GAE Python 2.5 project, you don't need any additional download because Webapp2 is shipped with the GAE SDK and can be imported independently of the Runtime adopted *.

Here is a trivial example on how to use Webapp2 in the old Python 2.5 runtime:

app.yaml

application: testwebapp2
version: 1
runtime: python
api_version: 1

handlers:
- url: .*
  script: main.py

main.py

import webapp2
class HelloWebapp2(webapp2.RequestHandler):
    def get(self):
        self.response.write('Hello, webapp2!')

app = webapp2.WSGIApplication([
    ('/', HelloWebapp2),
], debug=True)

def main():
    app.run()

if __name__ == '__main__':
    main()

* Just be sure to use the latest SDK available

Upvotes: 6

Related Questions