-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwsgi.py
More file actions
35 lines (28 loc) · 828 Bytes
/
wsgi.py
File metadata and controls
35 lines (28 loc) · 828 Bytes
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
# -*- coding: utf-8 -*-
from app import init_app
from flask import jsonify, redirect, url_for
from config import Config
app = init_app(Config)
@app.errorhandler(404)
def resource_not_found(err):
return jsonify(error=str(err)), 404
@app.errorhandler(Exception)
def internal_error(err):
# log the exception stack trace
app.logger.exception(err)
# create hr error message for response payload
message = [str(x) for x in err.args]
response = {
'success': False,
'error': {
'type': err.__class__.__name__,
'message': message
}
}
return jsonify(response), 500
@app.route("/")
def redirect_to_latest_api_version():
"""Redirects to /v1"""
return redirect(url_for("api.root"), code=302)
if __name__ == "__main__":
app.run(host='0.0.0.0')