-
Notifications
You must be signed in to change notification settings - Fork 0
/
DigiServer.py
44 lines (37 loc) · 844 Bytes
/
DigiServer.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
from bottle import route, run, template,response, get, post,request, static_file
import os
import time
import requests
import json
import csv
url = '192.168.0.56'
@route('/')
def home():
msg="hello"
return msg
@post('/data')
def receiveCo():
x= request.forms.get('x')
y= request.forms.get('y')
z= request.forms.get('z')
print x+" : "+y+" : "+z
file= open('data.csv',"a")
writer= csv.writer(file)
writer.writerow([x,y,z])
file.close()
@get('/userdata')
def sendData():
try:
readfile=open('data.csv',"rb")
except:
print "No file found"
val=""
reader=csv.reader(readfile)
lines=[l for l in reader]
for line in lines:
val= val+line[0] +","+line[1] + ","+line[2] +"\n"
readfile.close()
print val
os.remove('data.csv')
return val
run(host=url, port=8080, debug=True)