-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
40 lines (33 loc) · 1.38 KB
/
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
38
39
40
'''
mini-seerver to test files with apiviz
'''
# from pprint import pprint, pformat
from flask import Flask, render_template, send_from_directory, send_file
from flask_cors import CORS
app = Flask(__name__, template_folder='')
CORS(app)
@app.route("/content/<path:folder_path>/<string:filename>", methods=['GET'])
def serveHtml(folder_path, filename):
print("\n... serveHtml > folder_path : ", folder_path)
print("serveHtml > filename : ", filename)
return render_template( folder_path + '/' + filename )
@app.route('/statics/<path:folder_path>/<string:filename>')
def sendStatic(folder_path, filename):
print("\n... sendStatic > folder_path : ", folder_path)
print("sendStatic > filename : ", filename)
return send_from_directory(folder_path, filename)
@app.route('/raw/<path:folder_path>/<string:filename>')
def sendRawJson(folder_path, filename):
print("\n... sendRawJson > folder_path : ", folder_path)
print("sendRawJson > filename : ", filename)
resp = send_from_directory(folder_path, filename)
print("sendRawJson > resp : ", resp)
return resp
# @app.route('/images/<path:folder_path>/<string:filename>')
# def sendImage(folder_path, filename):
# print("folder_path : ", folder_path)
# print("filename : ", filename)
# return send_from_directory(folder_path, filename)
# run the application
if __name__ == "__main__":
app.run(debug=True, host='localhost', port=8900)