main.py 902 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/env python3

import os
import json
from flask import Flask, render_template, request
from lib.parse_paf import parse_paf

# Init Flash:
app = Flask(__name__, static_url_path='/static')

# Folder containing data:
app_data = "/home/fcabanettes/public_html/test"


# Root path
16
@app.route("/result/<id_res>", methods=['GET'])
17
def result(id_res):
18
    title = "IGenoComp - An Interactive Genome Comparator"
19
    return render_template("index.html", title=title, id=id_res)
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


@app.route('/get_graph', methods=['POST'])
def get_graph():
    id_f = request.form["id"]
    paf = os.path.join(app_data, id_f + ".paf")
    idx1 = os.path.join(app_data, id_f + "_1.idx")
    idx2 = os.path.join(app_data, id_f + "_2.idx")

    success, res = parse_paf(paf, idx1, idx2)

    if success:
        res["success"] = True
        return json.dumps(res)
    return json.dumps({"success": False, "message": res})