some errors in server, this refactor makes it work. Also return plugin_save...

This commit is contained in:
Ozbolt Menegatti 2019-09-23 13:25:59 +00:00
parent 52cc584c44
commit 476d139005
2 changed files with 9 additions and 10 deletions

View File

@ -53,6 +53,6 @@ editor: function(div, entry, uneditable) {
});
},
harvester: function(div) {
if(typeof plugin_save !== 'undefined') plugin_save(div);
if(typeof plugin_save !== 'undefined') return plugin_save(div);
}
}

View File

@ -94,21 +94,20 @@ def plugin_file(plugin, path):
redis.set(full_path + ":content", result)
redis.set(full_path + ":etag", etag)
resp = Response(result, mimetype=mt)
resp.headers.add('Access-Control-Allow-Origin', '*')
resp.headers.add('ETag', etag)
# set headers
headers = {
'Access-Control-Allow-Origin': '*',
'ETag': etag
}
# if browser does not have a cached etag -> 200
if 'If-None-Match' not in request.headers:
resp.status_code = 200
status_code = 200
# then check if it is the latest etag, else -> 200
elif request.headers['If-None-Match'] != etag:
resp.status_code = 200
# else just set whatever was predetermined
else:
resp.status_code = status_code
status_code = 200
return resp
return Response(result, mimetype=mt, headers=headers, status=status_code)
if __name__ == '__main__':
app.run(host="0.0.0.0")