Skip to content

Instantly share code, notes, and snippets.

@lewisrodgers
Last active March 26, 2018 01:01
Show Gist options
  • Save lewisrodgers/ec99848b22f22221f2b5a69d8fa90008 to your computer and use it in GitHub Desktop.
Save lewisrodgers/ec99848b22f22221f2b5a69d8fa90008 to your computer and use it in GitHub Desktop.
App Engine boilerplate

Some starter files to get up and running with App Engine and Flask.

Place home.html in a folder called templates.

The folder structure will look something like this:

— root/
  — lib/
  — templates/
    — index.html
  — app.yaml
  — main.py
  — requirements.txt
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: main.app
libraries:
- name: flask
version: latest
# Using third-party libraries: https://cloud.google.com/appengine/docs/standard/python/tools/using-libraries-python-27
from google.appengine.ext import vendor
vendor.add('lib')
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Hello world!</title>
</head>
<body>index
<h1>To be, or not to be...</h1>
</body>
</html>
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@app.errorhandler(500)
def server_error(e):
logging.exception('An error occurred during a request.')
return """
An internal error occurred: <pre>{}</pre>
See logs for full stacktrace.
""".format(e), 500
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment