-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.py
More file actions
35 lines (29 loc) · 1.16 KB
/
Copy pathapp.py
File metadata and controls
35 lines (29 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from flask import Flask, render_template, request, get_template_attribute
from models.LogManager import LogManager
from models.XMLManager import XMLManager
from models.SPARQLEndpointManager import SPARQLEndpointManager
from models.VerbalizeManager import VerbalizeManager
import json
LogManager.init()
XMLManager.init()
SPARQLEndpointManager.init("http://127.0.0.1:3030/solide/sparql")
LogManager.LogInfo('Starting Flask Application...')
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html', labels=XMLManager.GetRandomLabels(), version=XMLManager.GetLatestVersion())
@app.route('/', methods=['POST'])
def PostRequests():
if 'query' in request.form :
sparqlQuery = request.form['query']
verbilizer = VerbalizeManager(sparqlQuery)
return str(verbilizer.answer)
elif 'label' in request.form:
label = request.form['label']
queryLabel = XMLManager.GetSpecificQuery(label)
return queryLabel
elif 'sample' in request.form:
sampleQueries = XMLManager.GetRandomLabels()
return json.dumps(sampleQueries)
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0')