-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
37 lines (30 loc) · 1.22 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
'''
mini-seerver to test files loading
'''
# from pprint import pprint, pformat
from flask import Flask, render_template, send_from_directory, send_file, json
from flask_cors import CORS
app = Flask(__name__, template_folder='')
CORS(app)
@app.route("/", methods=['GET'])
def serveIndex():
print("\n... serveIndex > render index ...")
return render_template( "index.html" )
@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('/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=8802)