The Google Cloud team recently introduced a series of codelabs
(free, self-paced, hands-on tutorials) and corresponding
videos designed to help users on one of our serverless compute platforms modernize
their apps, with an initial focus on our earliest users running their apps on Google App Engine. We kick off this
content by showing users how to migrate from App Engine's webapp2
web framework to Flask, a popular framework in the Python
community.
While users have always been able to use other frameworks with App Engine,
webapp2
comes bundled with App Engine, making it
the default choice for many developers. One new requirement in App Engine's next generation
platform (which launched
in 2018) is that web frameworks must do their own routing, which unfortunately,
means that webapp2
is no longer supported, so here we are. The good
news is that as a result, modern App Engine is more flexible, lets users to develop in a more
idiomatic fashion, and makes their apps more portable.
For example, while webapp2
apps can run on App Engine, Flask apps can
run on App Engine, your servers, your data centers, or even on other clouds! Furthermore,
Flask has more users, more published resources, and is better supported. If Flask isn't right
for you, you can select from other WSGI-compliant
frameworks such as Django, Pyramid,
and others.
In this "Module 1" episode of Serverless Migration Station (part of the Serverless Expeditions series) Google engineer Martin Omander and I explore this migration and walk developers through it step-by-step.
In the previous
video, we introduced developers to the baseline Python 2 App Engine NDB
webapp2
sample app that we're taking through each of the migrations.
In the video above, users see that the majority of the changes are in the main application
handler, MainHandler
:
Upon (re)deploying the app, users should see no visible changes to the output from the original version:
Today's video picks up from where we left off: the Python 2 baseline app in its Module 0 repo folder. We call this the "START". By the time the migration has completed, the resulting source code, called "FINISH", can be found in the Module 1 repo folder. If you mess up partway through, you can rewind back to the START, or compare your solution with ours, FINISH. We also hope to one day provide a Python 3 version as well as cover other legacy runtimes like Java 8, PHP 5, and Go 1.11 and earlier, so stay tuned!
All of the migration learning modules, corresponding videos (when published), codelab
tutorials, START and FINISH code, etc., can all be found in the migration
repo. The next video (Module 2) will cover migrating from App Engine's
ndb
library for
Datastore to Cloud
NDB. We hope you find all these resources helpful in your quest to modernize your
serverless apps!