Skip to content

Commit c5dcf03

Browse files
committed
Fix hosts
1 parent c8cca34 commit c5dcf03

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

app.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from urllib.parse import urlparse
1010

1111
logging.basicConfig(filename='app.log', level=logging.DEBUG)
12+
logger = logging.getLogger(__name__)
1213

1314

1415
sparql_url = 'http://fuseki:3030/n4o'
@@ -115,23 +116,26 @@ def logout():
115116
response.delete_cookie('username')
116117
return response
117118

119+
def lhost():
120+
return urlparse(request.host).path.split(':')[0]
121+
118122
@app.route('/toSparql', methods=['GET', 'POST'])
119123
def toSparql():
120124
'''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
123126

124127
@app.route('/toAPI', methods=['GET', 'POST'])
125128
def toAPI():
126129
'''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
129131

130132
@app.route('/convert_lido', methods=['POST'])
131133
def convert_lido():
132134
''''Convert LIDO XML to RDF using the external service'''
133135
# 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
135139

136140

137141
@app.route('/import_ttl', methods=['POST'])

0 commit comments

Comments
 (0)