-
Notifications
You must be signed in to change notification settings - Fork 0
/
flask_nta.py
40 lines (32 loc) · 980 Bytes
/
flask_nta.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
import importlib
import json
import logging
import os
import pandas as pd
try:
from flask_cors import CORS
cors = True
except ImportError:
cors = False
from flask import Flask, Response, request, jsonify, render_template
from flask_restful import Resource, Api
from nta_flask.dsstox_rest import batch_query, ms2_query
app = Flask(__name__)
app.config.update(
DEBUG=False,
)
api = Api(app)
if cors:
CORS(app)
else:
logging.debug("CORS not enabled")
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
os.environ.update({
'PROJECT_ROOT': PROJECT_ROOT
})
# nta prefix needed if running from this file, to replicate url when running from flask_cgi using middleware
api.add_resource(batch_query.DsstoxBatchSearch, '/rest/ms1/batch/<string:jobId>')
api.add_resource(batch_query.DsstoxMSRFormulas, '/rest/ms1/list')
api.add_resource(ms2_query.MS2Search, '/rest/ms2/<string:jobId>')
if __name__ == '__main__':
app.run(port=7777, debug=False)