-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
executable file
·43 lines (32 loc) · 1.06 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""`main` is the top level module for your Flask application."""
# Imports
import os
import jinja2
import webapp2
import logging
JINJA_ENVIRONMENT = jinja2.Environment(
loader=jinja2.FileSystemLoader(os.path.dirname(__file__)),
extensions=['jinja2.ext.autoescape'],
autoescape=True)
# Import the Flask Framework
from flask import Flask, request
app = Flask(__name__)
# Note: We don't need to call run() since our application is embedded within
# the App Engine WSGI application server.
@app.route('/')
def index():
template = JINJA_ENVIRONMENT.get_template('templates/index.html')
# render the web page with the data
return template.render()
@app.route('/about')
def about():
template = JINJA_ENVIRONMENT.get_template('templates/about.html')
return template.render()
@app.errorhandler(404)
def page_not_found(e):
"""Return a custom 404 error."""
return 'Sorry, Nothing at this URL.', 404
@app.errorhandler(500)
def application_error(e):
"""Return a custom 500 error."""
return 'Sorry, unexpected error: {}'.format(e), 500