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";
$.getJSON(url, {
data : encodeURIComponent(JSON.stringify(params))
}).done(function(results) {
fetch(url, {
method : "POST",
body : JSON.stringify(params),
headers: {
'Content-Type': 'application/json'
}
}).then(
function(response) {
if (response.ok) {
return response.json()
}
}).then(
function(results) {
if (results.iarchive) {
self.iarchive = results.iarchive[0];
}
if (results.openlib) {
self.openlib = results.openlib[0];
}
if (!(results.openlib && results.iarchive)) {
self.noresources = true;
}
self.loading = false;
self.update();
});
})
}

5
src/website.py

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

Loading…
Cancel
Save