-
Notifications
You must be signed in to change notification settings - Fork 7
/
app_2.py
46 lines (32 loc) · 1.28 KB
/
app_2.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
import requests
import json
from flask import Response, Flask,render_template
import time
import csv, os
import pandas as pd
import flask
app = flask.Flask(__name__)
last = -1
@app.route('/')
def render():
return flask.render_template('index3.html')
@app.route('/pred')
def iter_all_rows():
global last
with open("stream.csv") as wfile:
reader = csv.reader(wfile)
for row_no,row in enumerate(reader):
num = row[0]
if row_no <= last:
continue
url = 'http://127.0.0.1:5000/results'
r = requests.post(url,json={'Wellhead Temp. (C)':row[0], 'Wellhead Press (psi)':row[1], 'MMCFD- gas':row[2],
'BOPD (barrel of oil produced per day)': row[3],'BWPD (barrel of water produced per day)': row[4],
'BSW - basic solid and water (%)': row[5],'CO2 mol. (%) @ 25 C & 1 Atm.': row[6], 'Gas Grav': row[7]})
last = row_no
return {'WellheadTemp':row[0], 'WellheadPressure':row[1], 'MMCFDgas':row[2],
"BOPD": row[3],'BWPD': row[4],
'BSW': row[5],"CO2": row[6], 'GasGrav': row[7],"predicted": r.json()}
time.sleep(5)
if __name__ == '__main__':
app.run(debug=True, port=5001)