From 8b8c64a2d260e526c4393d0adf921c6b7ffa6726 Mon Sep 17 00:00:00 2001 From: ange Date: Wed, 13 Jun 2018 16:49:14 +0200 Subject: [PATCH] edited getannot.py --- app/getannot.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/app/getannot.py b/app/getannot.py index aa23cee..8d3cab2 100644 --- a/app/getannot.py +++ b/app/getannot.py @@ -1,17 +1,7 @@ # #https://gist.github.com/mjlavin80/186a6395c5819dbe25a8a0e001d5acfd -# import requests -# import json - - - -# # This script demonstrates how to query annotations for a particular URL using the hypothes.is API. An API key is required. -# # The end result of this script is a Python dictionary with annotation data in it. Top save to csv or other format, further parsing would be required -# def get_annotations(): - - - +from flask import request import requests import json @@ -58,16 +48,17 @@ def get_annot_results(annot,name): def get_annot_book(annot,name): res=[] + server = request.host for item in annot['rows']: if 'selector' in item['target'][0]: if len(item['target'][0]['selector'])>2: string=item['uri'] - if name==string.replace('http://localhost:8080/uploads/',''): + if name==string.replace('http://' + server+'/uploads/',''): data={'text': item['text'],'extract':item['target'][0]['selector'][2]['exact'],'title':item['document']['title'], 'url':item['uri']} res.append(data) else: string=item['uri'] - if name==string.replace('http://localhost:8080/uploads/',''): + if name==string.replace('http://' + server+'/uploads/',''): data={'text': item['text'],'extract':item['target'][0]['selector'][1]['exact'],'title':item['document']['title'], 'url':item['uri']} res.append(data) return res