added static dir and serving for web ui

master
Kevin Froman 2018-07-27 00:48:22 -05:00
parent afdee2a7a5
commit d39208d648
No known key found for this signature in database
GPG Key ID: 0D414D0FE405B63B
1 changed files with 16 additions and 1 deletions

View File

@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
''' '''
import flask import flask
from flask import request, Response, abort from flask import request, Response, abort, send_from_directory
from multiprocessing import Process from multiprocessing import Process
from gevent.wsgi import WSGIServer from gevent.wsgi import WSGIServer
import sys, random, threading, hmac, hashlib, base64, time, math, os, logger, config import sys, random, threading, hmac, hashlib, base64, time, math, os, logger, config
@ -113,6 +113,21 @@ class API:
return resp return resp
@app.route('/client/ui/<path:path>')
def webUI(path):
startTime = math.floor(time.time())
if request.args.get('timingToken') is None:
timingToken = ''
else:
timingToken = request.args.get('timingToken')
self.validateHost('private')
endTime = math.floor(time.time())
elapsed = endTime - startTime
if not hmac.compare_digest(timingToken, self.timeBypassToken):
if elapsed < self._privateDelayTime:
time.sleep(self._privateDelayTime - elapsed)
return send_from_directory('static-data/ui/', path)
@app.route('/client/') @app.route('/client/')
def private_handler(): def private_handler():
if request.args.get('timingToken') is None: if request.args.get('timingToken') is None: