-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.py
126 lines (84 loc) · 2.35 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/usr/bin/env python
"""
Serverside app providing support
to CCP-NC database, main file
"""
import os
import sys
import json
import inspect
import ase
import flask
import soprano
from ccpncdb.server import MainServer
filepath = os.path.abspath(os.path.dirname(__file__))
# Create server app
serv = MainServer(filepath)
app = serv.app
### APP ROUTES ###
@app.route('/')
def root():
return serv.send_static('index.html')
@app.route('/cookies')
def cookiepol():
return serv.send_static('cookies.html')
@app.route('/logout')
def logout():
return serv.logout()
@app.route('/gettokens/', defaults={'code': None})
@app.route('/gettokens/<code>')
def get_tokens(code):
return serv.get_tokens(code)
@app.route('/upload', methods=['POST'])
def upload():
return serv.upload_record()
@app.route('/edit', methods=['POST'])
def edit():
return serv.upload_version()
@app.route('/hide', methods=['POST'])
def hide():
return serv.hide_record()
@app.route('/search', methods=['POST'])
def search():
return serv.search()
@app.route('/get_record', methods=['POST'])
def get_record():
return serv.get_record()
@app.route('/get_magres', methods=['GET'])
def get_magres():
return serv.get_magres()
@app.route('/get_csv', methods=['GET'])
def get_csv():
return serv.get_csv()
@app.route('/csvtemplate', methods=['GET'])
def get_csv_template():
return serv.get_csv_template()
@app.route('/download_selection_zip', methods=['POST'])
def download_selection_zip():
return serv.download_selection_zip()
@app.route('/download_selection_json', methods=['POST'])
def download_selection_json():
return serv.download_selection_json()
@app.route('/sendmail', methods=['POST'])
def send_mail():
return serv.send_mail()
@app.route('/pyversion', methods=['GET'])
def get_version():
resp = """
<ul>
<li>Python: {pyv}</li>
<li>ASE: {asev}</li>
<li>Soprano: {sprv}</li>
<li>Flask: {flkv}</li>
</ul>
""".format(pyv=sys.version, asev=ase.__version__,
sprv=soprano.__version__, flkv=flask.__version__)
return resp
if __name__ == '__main__':
# Run locally; only launch this way when testing!
# Authorise cross-origin for the sake of local testing
from flask_cors import CORS
CORS(app)
app.debug = True
app.config['SERVER_NAME'] = 'localhost:8000'
app.run(port=8000, threaded=True)