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

minimal-plugin
Ozbolt Menegatti 5 years ago
parent 52cc584c44
commit 476d139005

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

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

Loading…
Cancel
Save