- app.yaml Select all
#change application name to new id that enable HRD
#application: myapp
application: myapp-hrd
#change runtime
#runtime: python
runtime: python27
#add threadsafe
threadsafe: true
#change remote_api
handlers:
#- url: /remote_api
# script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py
# login: admin
- url: /remoteapi.*
script: google.appengine.ext.remote_api.handler.app
login: admin
#change url for app
- url: .*
script: myapp.app
# script: myapp.py
#add libraries
libraries:
- name: webapp2
version: "2.5.2"
- name: jinja2
version: "2.6"
#add services
inbound_services:
- warmup
- myapp.py Select all
#import webapp2 and jinja2
import webapp2
import jinja2
#import wsgiref.handlers
#from google.appengine.ext import webapp
#from google.appengine.ext.webapp import RequestHandler
#from google.appengine.ext.webapp import template
#from google.appengine.ext.webapp.util import run_wsgi_app
#use ndb instead of db
#from google.appengine.ext import db
#class Greeting(db.Model):
# author = db.UserProperty()
# content = db.StringProperty(indexed=False)
# role = db.StringProperty(required=True, choices=set(["executive", "manager", "helper"]))
# date = db.DateTimeProperty(auto_now_add=True)
from google.appengine.ext import ndb
class Greeting(ndb.Model):
"""Models an individual Guestbook entry with author, content, and date."""
author = ndb.UserProperty()
content = ndb.StringProperty(indexed=False)
role = ndb.StringProperty(required=True, choices=set(["executive", "manager", "helper"]))
date = ndb.DateTimeProperty(auto_now_add=True)
#use TEMPLATE_DIR and JINJA_ENVIRONMENT
TEMPLATE_DIR = 'templates'
JINJA_ENVIRONMENT = jinja2.Environment(
loader=jinja2.FileSystemLoader(os.path.join(os.path.dirname(__file__), TEMPLATE_DIR)),
# loader=jinja2.FileSystemLoader(os.path.dirname(__file__)),
extensions=['jinja2.ext.autoescape'])
#use jinja2 template
# path = os.path.abspath(os.path.join(os.path.dirname(__file__), TEMPLATE_DIR, fileName))
# self.response.out.write(template.render(path, values))
template = JINJA_ENVIRONMENT.get_template(fileName)
self.response.write(template.render(values))
#use webapp2 instead of webapp
#def main():
#application = webapp.WSGIApplication(
app = webapp2.WSGIApplication(
[('/', MainHandler)
# %3D does not work now
# ,(r'/id%3D([A-Za-z0-9-.]*)', IDHandler)
,(r'/id=([A-Za-z0-9-.]*)', IDHandler)
], debug=True)
# run_wsgi_app(application)
#if __name__ == '__main__':
# main()
Then, Duplicate Application Settings to a new application id say myapp-hrd
Finally, Migrate the app to the High Replication Datastore (HRD) in Google App Engine admin before uploading the python 2.7 code to the newly converted application id myapp-hrd
At the end of the migration process, the new HRD app (myapp-hrd) will be aliased to the old appid.