forked from quanted/cts_app
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.py
42 lines (29 loc) · 1.04 KB
/
test.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
from django.http import HttpResponse
import logging
import json
import requests
baseUrl = 'http://pnnl.cloudapp.net/webservices' # This will soon change to a local cgi server
headers = {'Content-Type' : 'application/json'}
def testPage(request, chem):
structures = [{ "structure" : chem }]
include = ["structureData"]
additionalFields = {
"iupac" : "chemicalTerms(name)",
"formula" : "chemicalTerms(formula)",
"mass" : "chemicalTerms(mass)",
"smiles" : "chemicalTerms(molString('smiles'))"
}
parameters = { "structureData" : "mrv" }
display = {"include":include, "additionalFields":additionalFields, "parameters":parameters}
details = {"structures":structures, "display":display}
data = json.dumps(details)
url = baseUrl + '/rest-v0/util/detail/'
chemDetails = requests.post(url, data=data, headers=headers)
fileout = open('C:\\Users\\nickpope\\Desktop\\out.txt', 'w')
fileout.write(data)
fileout.close()
# return response
response = HttpResponse()
response.write(chemDetails.content)
logging.warning(response)
return response