forked from priya-vijay/TimeRx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
67 lines (56 loc) · 1.78 KB
/
main.py
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
from flask import Flask
from flask import request
from flask import render_template
import pandas as pd
import os
import sys
sys.path.insert(0, './kinetizer')
sys.path.insert(0, './plotter')
from plotarea import plot
from kinetizer import Kinetizer
app = Flask(__name__)
def getdata(druglist):
os.chdir("kinetizer")
# currently hard coded starttimes
starttimes={'nadolol':1200, 'simvastin':480, 'atazanavir':1200, 'vicodin':660}
kinetizerinput = {}
for drug in druglist:
kinetizerinput[drug] = {'start_time':starttimes[drug]}
kin = Kinetizer(kinetizerinput)
concdata = kin.return_dataframe()
# schedule = kin.get_schedule()
# schedule.to_csv("templates/schedule.csv")
os.chdir("../")
# return concdata, schedule
return concdata, None
# # # placeholders for functions to be imported
# def druvasfunction():
# pass
@app.route('/')
def my_form():
return render_template("form.html")
@app.route('/', methods=['POST'])
def form():
name = request.form['name']
drug1 = request.form['drug1']
dose1 = request.form['dose1']
drug2 = request.form['drug2']
dose2 = request.form['dose2']
drug3 = request.form['drug3']
dose3 = request.form['dose3']
drug4 = request.form['drug4']
dose4 = request.form['dose4']
# check if drugs are specified
drugsinput = []
for drug in [drug1, drug2, drug3, drug4]:
if len(drug) > 0:
drugsinput.append(drug)
concdict, scheddict = getdata(drugsinput)
plot(concdict, "templates/areaplot.html")
# druvasfunction("templates/schedule.csv", "templates/areaplot.html", "report.html")
# processed_text = drug1 + dose1
# return processed_text
return render_template("areaplot.html")
if __name__ == '__main__':
app.debug = True
app.run()