-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
70 lines (50 loc) · 1.78 KB
/
app.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""
Flask Documentation: http://flask.pocoo.org/docs/
Jinja2 Documentation: http://jinja.pocoo.org/2/documentation/
Werkzeug Documentation: http://werkzeug.pocoo.org/documentation/
This file creates your application.
"""
import os
from flask import Flask, jsonify, abort, make_response, render_template, request, redirect, url_for
from flask_restful import Api
app = Flask(__name__)
api = Api(app)
from resources import RecordListResource
from resources import RecordResource
app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY', 'this_should_be_configured')
api.add_resource(RecordListResource, '/api/v1.0/records', endpoint='records')
api.add_resource(RecordResource, '/api/v1.0/records/<string:id>', endpoint='record')
###
# Routing for your application.
###
@app.route('/')
def home():
"""Render website's home page."""
return render_template('home.html')
# @app.route('/about/')
# def about():
# """Render the website's about page."""
# return render_template('about.html')
###
# The functions below should be applicable to all Flask apps.
###
# @app.route('/<file_name>.txt')
# def send_text_file(file_name):
# """Send your static text file."""
# file_dot_text = file_name + '.txt'
# return app.send_static_file(file_dot_text)
# @app.after_request
# def add_header(response):
# """
# Add headers to both force latest IE rendering engine or Chrome Frame,
# and also to cache the rendered page for 10 minutes.
# """
# response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1'
# response.headers['Cache-Control'] = 'public, max-age=600'
# return response
# @app.errorhandler(404)
# def page_not_found(error):
# """Custom 404 page."""
# return render_template('404.html'), 404
if __name__ == '__main__':
app.run(debug=True)