aboutsummaryrefslogtreecommitdiffstats
path: root/fatcat
diff options
context:
space:
mode:
Diffstat (limited to 'fatcat')
-rw-r--r--fatcat/api_client.py11
-rw-r--r--fatcat/routes.py24
2 files changed, 4 insertions, 31 deletions
diff --git a/fatcat/api_client.py b/fatcat/api_client.py
index e371b727..0c9336ee 100644
--- a/fatcat/api_client.py
+++ b/fatcat/api_client.py
@@ -12,13 +12,10 @@ class FatCatApiClient:
def get(self, path):
return self.session.get(self.host_url + path)
- def post(self, path, data=None, headers=None):
- hdrs = {"content-type": "application/json"}
- if headers:
- hdrs.update(headers)
- #if type(data) == dict:
- # data = json.dumps(data, indent=None).encode('utf-8')
- return self.session.post(self.host_url + path, json=data, headers=hdrs)
+ def post(self, path, data=None):
+ headers = {"content-type": "application/json"}
+ return self.session.post(self.host_url + path, json=data,
+ headers=headers)
def import_crossref_file(self, json_file):
eg = self.new_editgroup()
diff --git a/fatcat/routes.py b/fatcat/routes.py
index b1568833..ba12043d 100644
--- a/fatcat/routes.py
+++ b/fatcat/routes.py
@@ -21,18 +21,12 @@ def work_random():
@app.route('/work/<int:ident>', methods=['GET'])
def work_view(ident):
rv = api.api_work_get(ident)
- if rv.status_code != 200:
- # TODO: better wrapping for all entities
- return abort(rv.status_code)
entity = json.loads(rv.data.decode('utf-8'))
return render_template('work_view.html', work=entity)
@app.route('/release/<int:ident>', methods=['GET'])
def release_view(ident):
rv = api.api_release_get(ident)
- if rv.status_code != 200:
- # TODO: better wrapping for all entities
- return abort(rv.status_code)
entity = json.loads(rv.data.decode('utf-8'))
return render_template('release_view.html', release=entity)
@@ -45,36 +39,24 @@ def release_random():
@app.route('/creator/<int:ident>', methods=['GET'])
def creator_view(ident):
rv = api.api_creator_get(ident)
- if rv.status_code != 200:
- # TODO: better wrapping for all entities
- return abort(rv.status_code)
entity = json.loads(rv.data.decode('utf-8'))
return render_template('creator_view.html', creator=entity)
@app.route('/container/<int:ident>', methods=['GET'])
def container_view(ident):
rv = api.api_container_get(ident)
- if rv.status_code != 200:
- # TODO: better wrapping for all entities
- return abort(rv.status_code)
entity = json.loads(rv.data.decode('utf-8'))
return render_template('container_view.html', container=entity)
@app.route('/file/<int:ident>', methods=['GET'])
def file_view(ident):
rv = api.api_file_get(ident)
- if rv.status_code != 200:
- # TODO: better wrapping for all entities
- return abort(rv.status_code)
entity = json.loads(rv.data.decode('utf-8'))
return render_template('file_view.html', file=entity)
@app.route('/editgroup/<int:ident>', methods=['GET'])
def editgroup_view(ident):
rv = api.api_editgroup_get(ident)
- if rv.status_code != 200:
- # TODO: better wrapping for all entities
- return abort(rv.status_code)
entity = json.loads(rv.data.decode('utf-8'))
return render_template('editgroup_view.html', editgroup=entity)
@@ -86,18 +68,12 @@ def editgroup_current():
@app.route('/editor/<username>', methods=['GET'])
def editor_view(username):
rv = api.api_editor_get(username)
- if rv.status_code != 200:
- # TODO: better wrapping for all entities
- return abort(rv.status_code)
entity = json.loads(rv.data.decode('utf-8'))
return render_template('editor_view.html', editor=entity)
@app.route('/editor/<username>/changelog', methods=['GET'])
def editor_changelog(username):
rv = api.api_editor_get(username)
- if rv.status_code != 200:
- # TODO: better wrapping for all entities
- return abort(rv.status_code)
editor = json.loads(rv.data.decode('utf-8'))
rv = api.api_editor_changelog(username)
changelog_entries = json.loads(rv.data.decode('utf-8'))