fixes not concerning graphics

- default is no graphics
- use send_file instead of response (proper mimetype)
- fix issues with parameter blocks
This commit is contained in:
l_samenv
2021-09-17 15:37:04 +02:00
parent fbe70ce68a
commit b55e51fc65
8 changed files with 34 additions and 38 deletions

28
seaweb.py Normal file → Executable file
View File

@@ -37,6 +37,7 @@ def guess_mimetype(filename):
mimetype = 'text/css'
elif filename.endswith('.ico'):
mimetype = 'image/x-icon'
print('mimetype', mimetype)
else:
mimetype = 'text/html'
return mimetype
@@ -141,12 +142,7 @@ def reply():
@app.route('/test/<file>')
def subdir_test_file(file):
gevent.sleep(2)
try:
with open("client/test/"+file, 'r') as content_file:
content = content_file.read()
except IOError:
flask.abort(404)
resp = flask.Response(content, mimetype=guess_mimetype(file))
resp = flask.send_file("client/test/"+file, mimetype=guess_mimetype(file))
return resp
@app.route('/jsFiles/<file>')
@@ -154,12 +150,7 @@ def subdir_test_file(file):
@app.route('/externalFiles/<file>')
def subdir_file(file):
subdir = flask.request.path.split('/')[1]
try:
with open("client/" + subdir+"/"+file, 'r') as content_file:
content = content_file.read()
except IOError:
flask.abort(404)
resp = flask.Response(content, mimetype=guess_mimetype(file))
resp = flask.send_file("client/" + subdir+"/"+file, mimetype=guess_mimetype(file))
#resp.headers['Content-Security-Policy'] = "sandbox; script-src 'unsafe-inline';"
return resp
@@ -174,12 +165,7 @@ def default():
@app.route('/<file>')
def general_file(file):
subdir = "client/"
try:
with open(subdir+file, 'r') as content_file:
content = content_file.read()
except IOError:
flask.abort(404)
resp = flask.Response(content, mimetype=guess_mimetype(file))
resp = flask.send_file(subdir+file, mimetype=guess_mimetype(file))
#resp.headers['Content-Security-Policy'] = "sandbox; script-src 'unsafe-inline';"
return resp
@@ -332,7 +318,7 @@ class SeaInstrument(Instrument):
def poll_groups(self, paths):
'polls values and components of requested groups'
for path in paths:
for path in list(paths):
gobj = self.groups[path]
now = time.time()
if now < gobj.lastpoll + 0.5:
@@ -627,7 +613,9 @@ class SeaClient(SeaGraph):
def w_getblock(self, path):
gobj = instrument.findgroup(path.split(',')[-1])
self.group_version[path] = gobj.version
# self.group_version[path] = gobj.version
# simplify: allow only one group per client
self.group_version = {path: gobj.version}
logging.info('getblock %s %d', path, gobj.version)
return dict(type='draw', title=gobj.grouptitle, path=path, components=gobj.components)