Browse Source

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

master
Ozbolt Menegatti 1 year ago
parent
commit
476d139005
2 changed files with 9 additions and 10 deletions
  1. +1
    -1
      plugin-loader.js
  2. +8
    -9
      plugin-server.py

+ 1
- 1
plugin-loader.js 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);
}
}

+ 8
- 9
plugin-server.py 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")

Loading…
Cancel
Save