-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Fox.Lee
committed
Nov 26, 2012
1 parent
fc7c5b0
commit 20b835b
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import android | ||
from urllib.parse import urlencode | ||
from urllib.request import urlopen | ||
|
||
server_title = 'Which server should i use' | ||
server_msg = "Plse confirm the server address/name to use for your athlete's timing data:" | ||
timing_title = 'Enter data' | ||
timing_msg = 'Provide a new timing value:' | ||
web_server = 'http://192.168.1.180:8082' | ||
add_time_cgi = '/cgi-bin/add_timing_data.py' | ||
|
||
app = android.Android() | ||
|
||
def send_to_server (url, post_data=None): | ||
if post_data: | ||
page = urlopen(url,urlencode(post_data).encode('utf-8')) | ||
else: | ||
page = urlopen(url) | ||
return(page.read().decode('utf8')) | ||
|
||
resp = app.dialogGetInput(server_title,server_msg,web_server).result | ||
|
||
if resp is not None: | ||
web_server = resp | ||
resp = app.dialogGetInput(timing_title,timing_msg).result | ||
|
||
if resp is not None: | ||
new_time = resp | ||
send_to_server(web_server+add_time_cgi,{'Timingvalue':new_time}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import cgi | ||
import os | ||
import time | ||
import sys | ||
import YATE | ||
|
||
print (YATE.start_response('text/plain')) | ||
addr = os.environ['REMOTE_ADDR'] | ||
host = os.environ['REMOTE_HOST'] | ||
method = os.environ['REQUEST_METHOD'] | ||
cur_time = time.asctime(time.localtime()) | ||
|
||
print (host+", "+addr+", "+cur_time+": "+method, file=sys.stderr) | ||
|
||
form = cgi.FieldStorage() | ||
|
||
for each_form_item in form.keys(): | ||
print (each_form_item + '->' + form[each_form_item].value, | ||
end=' ', file=sys.stderr) | ||
print (file = sys.stderr) #在标准错误输出上换行 | ||
print ('OK.') |