Browse Source

use fetch for getting books, use request.json and set the request as

application/json
master
wes 8 years ago
parent
commit
a58566d9d9
  1. 21
      src/scripts/book.tag
  2. 5
      src/website.py

21
src/scripts/book.tag

@ -45,24 +45,31 @@ getresources(ev) {
}; };
var url = "/search/resources"; var url = "/search/resources";
$.getJSON(url, { fetch(url, {
data : encodeURIComponent(JSON.stringify(params)) method : "POST",
}).done(function(results) { body : JSON.stringify(params),
headers: {
'Content-Type': 'application/json'
}
}).then(
function(response) {
if (response.ok) {
return response.json()
}
}).then(
function(results) {
if (results.iarchive) { if (results.iarchive) {
self.iarchive = results.iarchive[0]; self.iarchive = results.iarchive[0];
} }
if (results.openlib) { if (results.openlib) {
self.openlib = results.openlib[0]; self.openlib = results.openlib[0];
} }
if (!(results.openlib && results.iarchive)) { if (!(results.openlib && results.iarchive)) {
self.noresources = true; self.noresources = true;
} }
self.loading = false; self.loading = false;
self.update(); self.update();
}); })
} }

5
src/website.py

@ -74,9 +74,8 @@ def ClassSearch(configfile=None):
def resources(): def resources():
""" Get Resources """ """ Get Resources """
notRequired = False notRequired = False
try: params = request.json
params = loads(unquote(dict(request.args.items())["data"])) if params is None:
except KeyError:
return jsonify(False) return jsonify(False)
print(params) print(params)
author = params["author"] author = params["author"]

Loading…
Cancel
Save