|
9 | 9 | from urllib.parse import urlparse |
10 | 10 |
|
11 | 11 | logging.basicConfig(filename='app.log', level=logging.DEBUG) |
| 12 | +logger = logging.getLogger(__name__) |
12 | 13 |
|
13 | 14 |
|
14 | 15 | sparql_url = 'http://fuseki:3030/n4o' |
@@ -115,23 +116,26 @@ def logout(): |
115 | 116 | response.delete_cookie('username') |
116 | 117 | return response |
117 | 118 |
|
| 119 | +def lhost(): |
| 120 | + return urlparse(request.host).path.split(':')[0] |
| 121 | + |
118 | 122 | @app.route('/toSparql', methods=['GET', 'POST']) |
119 | 123 | def toSparql(): |
120 | 124 | '''Call sparql UI service''' |
121 | | - host = urlparse(request.host).path.split(':')[0] |
122 | | - return redirect(f'http://{host}:8000/sparql') #OK |
| 125 | + return redirect(f'http://{lhost()}:8000/sparql') #OK |
123 | 126 |
|
124 | 127 | @app.route('/toAPI', methods=['GET', 'POST']) |
125 | 128 | def toAPI(): |
126 | 129 | '''Call sparql UI service''' |
127 | | - host = urlparse(request.host).path.split(':')[0] |
128 | | - return redirect(f'http://{host}:5020') #OK |
| 130 | + return redirect(f'http://{lhost()}:5020') #OK |
129 | 131 |
|
130 | 132 | @app.route('/convert_lido', methods=['POST']) |
131 | 133 | def convert_lido(): |
132 | 134 | ''''Convert LIDO XML to RDF using the external service''' |
133 | 135 | # curl -X POST -H "Content-Type: application/json" -d '{"data":"<lido/>", "format":"nt"}' converter:5000/runMappings |
134 | | - return requests.post(lido2rdf_url(), data=request.json['data']).text |
| 136 | + data = request.json['data'] |
| 137 | + logger.info(f'Converting LIDO 2 data of length {len(data)}') |
| 138 | + return requests.post(f'http://{lhost()}:5000/convert', data=data).text |
135 | 139 |
|
136 | 140 |
|
137 | 141 | @app.route('/import_ttl', methods=['POST']) |
|
0 commit comments