-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
executable file
·32 lines (27 loc) · 745 Bytes
/
test.py
File metadata and controls
executable file
·32 lines (27 loc) · 745 Bytes
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
#!/usr/bin/env python
import json
import time
# Import modules for CGI handling
import cgi, cgitb
# Create instance of FieldStorage
form = cgi.FieldStorage()
# The input looks like 'a=1&b=2&c=hi+there'.
#post_message = raw_input()
#data_dict = {}
#for line in post_message.strip().split('&'):
# try:
# k, v = line.split('=', 1)
# except:
# continue
# data_dict[k] = v.replace('+', ' ')
results = {'message': 'telescopes are 95',
'date': time.asctime()}
input1 = form.getvalue('text_input1')
if input1 is not None:
results['also'] = 'You said ' + input1
else:
results['also'] = 'Button=%s' % form.getvalue('button')
text = json.dumps(results)
print 'Content-type: application/json'
print
print text