- Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path__init__.py
executable file
·71 lines (52 loc) · 1.8 KB
/
__init__.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
68
69
70
71
# from flask import render_template, Flask, url_for
# app = Flask(__name__)
# @app.route('/hello')
# def hello(name=None):
# url_for('static', filename='testTags.js')
# return render_template('search.html')
importcsv
fromjsonimportdump
fromshutilimportcopy2
fromsubprocessimportcall
importre
importfileinput
importos
fromflaskimportFlask, jsonify, render_template, request, session, redirect, current_app
frompdfkitimportfrom_url, from_file
app=Flask(__name__)
frommathimportceil
importlogging
logging.basicConfig(level=logging.DEBUG)
rootPath="/var/www/html/semapp/"
pyPath="/usr/bin/python"
# rootPath = "/Users/bchartof/Projects/state-economic-monitor/"
# pyPath = "/usr/bin/python2.7"
@app.route("/upload", methods=["POST", "GET"])
defupload():
ifrequest.method=='POST':
file=request.files['file']
sheet=request.args.get('sheet', '', type=str)
printsheet
file.save(rootPath+"static/data/source/"+sheet+".xlsx")
return""
@app.route('/add', methods=["POST", "GET"])
defupdate_SEM():
printrequest.json
#write a pretty printed json for human readability
withopen(rootPath+'static/data/cards/prettyCards.json', 'wt') asout:
res=dump(request.json, out, sort_keys=True, indent=4, separators=(',', ': '))
#write a one line json for consumption in JS
withopen(rootPath+'static/data/cards/cards.json', 'wt') asout:
res=dump(request.json, out, sort_keys=True, separators=(',', ':'))
os.system(pyPath+" "+rootPath+"reshape.py")
os.system(pyPath+" "+rootPath+"zipper.py")
returnjsonify({})
@app.route('/')
defindex():
returnrender_template('updater.html')
@app.route('/preview')
defpreview():
returnrender_template('preview.html')
if__name__=='__main__':
app.debug=True
app.run(threaded=True)