-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.py
More file actions
75 lines (54 loc) · 1.93 KB
/
app.py
File metadata and controls
75 lines (54 loc) · 1.93 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
from flask import Flask, render_template, request, make_response, jsonify, redirect, url_for
import base64, os
from tempfile import NamedTemporaryFile
import uuid
from copy import copy
from EMDMeasurment.ComparisonMethods import produce_visualizations_from_event_logs_paths
from flask_cors import CORS
import json
import traceback
app = Flask(__name__)
CORS(app, expose_headers=["x-suggested-filename"])
logs_dictio = {}
@app.route('/')
def empty_path():
return redirect(url_for('upload_page'))
@app.route('/index.html')
def index():
return redirect(url_for('upload_page'))
@app.route("/comparison.html")
def comparison_page():
return render_template("comparison.html")
@app.route("/upload.html")
def upload_page():
return render_template("upload.html")
@app.route("/visualizationsService", methods=["GET"])
def visualizationsService():
uid1 = request.args.get("uuid1")
uid2 = request.args.get("uuid2")
if uid1 is None:
uid1 = "log1"
if uid2 is None:
uid2 = "log2"
log_path1 = logs_dictio[uid1]
log_path2 = logs_dictio[uid2]
resp = produce_visualizations_from_event_logs_paths(log_path1, log_path2)
return jsonify(resp)
@app.route("/uploadService", methods=["POST"])
def upload():
uuids = []
for file in request.files:
tmp_file = NamedTemporaryFile()
tmp_file.close()
fo = request.files[file]
fo.save(tmp_file.name)
this_uuid = str(uuid.uuid4())
logs_dictio[this_uuid] = tmp_file.name
uuids.append(this_uuid)
return {"uuid1": uuids[0], "uuid2": uuids[1]}
if __name__ == "__main__":
if not os.path.exists(os.path.join("static", "temp")):
os.mkdir(os.path.join("static", "temp"))
logs_dictio["log1"] = os.path.join("SampleEventLogs&SimulatedER2021", "running-example.xes")
logs_dictio["log2"] = os.path.join("SampleEventLogs&SimulatedER2021", "Running-example-simulated.csv")
app.run(host='0.0.0.0')