In this step you will rewrite your Python application to use the Flask web framework. You must also modify your Dockerfile to install required Python dependencies from a requirements.txt file using pip.
Edit the project files
requirements.txt
Create the file requirements.txt listing Flask as a dependency
Flask==0.10.1
Dockerfile
Modify Dockerfile as shown:
main.py
Replace main.py with the code below, which uses flask.route decorator instead of webapp2.RequestHandler.
The two classes HelloHandler and MessagesHandler are replaced by the functions fortune() and messages().
Test and deploy
Run locally
$ gcloud preview app run ./app.yaml
And visit http://localhost:8080/. Reload the page a few times, then try http://localhost:8080/messages.
Deploy to the cloud
$ gcloud preview app deploy ./app.yaml
Point your browser at your appspot address (http://<your-app-id>.appspot.com/).
Reload the page a few times, then try http://<your-app-id>.appspot.com/messages.
Next
In the next step you'll add a native C text-to-speech synthesizer and create a sound file that reads your fortune out loud.