-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmySite.py
More file actions
68 lines (54 loc) · 2.17 KB
/
Copy pathmySite.py
File metadata and controls
68 lines (54 loc) · 2.17 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
# import the necessary packages
import flask, render_template, redirect, url_for, request,session,Response
from werkzeug import secure_filename
import os
#from supportFile import *
import pickle
from sms import sendSMS
import sqlite3
from datetime import datetime
import pandas as pd
app = Flask(__name__)
app.secret_key = '1234'
app.config["CACHE_TYPE"] = "null"
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
@app.route('/', methods=['GET', 'POST'])
def landing():
return render_template('home.html')
@app.route('/home', methods=['GET', 'POST'])
def home():
return render_template('home.html')
@app.route('/input', methods=['GET', 'POST'])
def input():
if request.method == 'POST':
if request.form['sub']=='Upload':
savepath = r'upload/'
dataset = request.files['dataset']
dataset.save(os.path.join(savepath,(secure_filename('dataset.csv'))))
return render_template('input.html',mgs="Dataset Uploaded..!!!")
return render_template('input.html')
@app.route('/dataset', methods=['GET', 'POST'])
def dataset():
df = pd.read_csv('upload/dataset.csv')
return render_template('dataset.html', tables=[df.to_html(classes='w3-table-all w3-hoverable')], titles=df.columns.values)
@app.route('/clean', methods=['GET', 'POST'])
def clean():
df = pd.read_csv('upload/dataset.csv')
df.drop(['id_str', 'screen_name',
'location', 'description',
'url', 'created_at',
'lang', 'status',
'default_profile',
'default_profile_image',
'has_extended_profile','name'],axis=1,inplace=True)
return render_template('clean.html', tables=[df.to_html(classes='w3-table-all w3-hoverable')], titles=df.columns.values)
# No caching at all for API endpoints.
@app.after_request
def add_header(response):
# response.cache_control.no_store = True
response.headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0'
response.headers['Pragma'] = 'no-cache'
response.headers['Expires'] = '-1'
return response
if __name__ == '__main__':
app.run(host='0.0.0.0', debug=True, threaded=True)