-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
37 lines (24 loc) · 944 Bytes
/
server.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
import os
from flask import jsonify, redirect, request, make_response, send_from_directory, url_for
from app import app
ROOT_PATH = os.path.dirname(os.path.realpath(__file__))
PUBLIC_PATH = os.path.join(ROOT_PATH, 'build')
VERSION = os.getenv('VERSION', 'v0.1.0')
app.static_folder = os.path.join(PUBLIC_PATH, 'static')
@app.errorhandler(404)
def not_found(error):
""" error handler """
return redirect('/')
@app.route('/<path:filename>')
@app.route('/')
def index(filename='index.html'):
return send_from_directory(PUBLIC_PATH, filename)
@app.route('/ping', methods=['GET'])
def ping_server():
""" Testing endpoint """
return jsonify({'ok': True, 'message': 'imsearch test server version {} up and running'.format(VERSION)}), 200
def run_server():
port = int(os.environ.get('PORT', "8080"))
app.run(host='0.0.0.0', port=port, debug=True, use_reloader=False)
if __name__ == "__main__":
run_server()