|
16 | 16 |
|
17 | 17 |
|
18 | 18 | import webapp2 |
19 | | -from google.appengine.ext import ndb |
20 | | - |
21 | | - |
22 | | -class StationMetric(ndb.Model): |
23 | | - """ |
24 | | - Thermometer for measuring air and sea surface temperature |
25 | | - Barometer for measuring atmospheric pressure |
26 | | - Hygrometer for measuring humidity. |
27 | | - Anemometer for measuring wind speed |
28 | | - Rain gauge for measuring liquid precipitation over a set period of time. |
29 | | - Present Weather/Precipitation Identification Sensor for identifying falling precipitation |
30 | | - Disdrometer for measuring drop size distribution |
31 | | - Transmissometer for measuring visibility |
32 | | - Ceilometer for measuring cloud ceiling |
33 | | - """ |
34 | | - stationid = ndb.StringProperty() |
35 | | - recorded = ndb.DateTimeProperty(auto_now_add=True) |
36 | | - temperature = ndb.FloatProperty() |
37 | | - pressure = ndb.FloatProperty() |
38 | | - humidity = ndb.FloatProperty() |
39 | | - windspeed = ndb.FloatProperty() |
40 | | - precipitation = ndb.FloatProperty() |
41 | | - dropsize = ndb.FloatProperty() |
42 | | - visibility = ndb.FloatProperty() |
43 | | - ceiling = ndb.FloatProperty() |
44 | 19 |
|
45 | 20 |
|
46 | 21 | class HomeHandler(webapp2.RequestHandler): |
47 | 22 | def get(self): |
48 | 23 | self.response.headers['Content-Type'] = 'text/plain' |
49 | | - self.response.write('Workload Simulation Using Containers as Clients\n') |
| 24 | + self.response.write('Welcome to Simulating Workloads Using Containers as Clients\n') |
50 | 25 |
|
51 | 26 |
|
52 | 27 | class LoginHandler(webapp2.RequestHandler): |
53 | 28 | def post(self): |
54 | | - stationid = self.request.get('stationid') |
| 29 | + deviceid = self.request.get('deviceid') |
55 | 30 | self.response.headers['Content-Type'] = 'text/plain' |
56 | | - self.response.write('/login - station: {}\n'.format(stationid)) |
| 31 | + self.response.write('/login - device: {}\n'.format(deviceid)) |
57 | 32 |
|
58 | 33 |
|
59 | 34 | class MetricsHandler(webapp2.RequestHandler): |
60 | 35 | def post(self): |
61 | | - stationid = self.request.get('stationid') |
62 | | - |
63 | | - sm = StationMetric( |
64 | | - stationid = stationid, |
65 | | - temperature = float(self.request.get('temperature')), |
66 | | - pressure = float(self.request.get('pressure')), |
67 | | - humidity = float(self.request.get('humidity')), |
68 | | - windspeed = float(self.request.get('windspeed')), |
69 | | - precipitation = float(self.request.get('precipitation')), |
70 | | - dropsize = float(self.request.get('dropsize')), |
71 | | - visibility = float(self.request.get('visibility')), |
72 | | - ceiling = float(self.request.get('ceiling')) |
73 | | - ) |
74 | | - smkey = sm.put() |
| 36 | + deviceid = self.request.get('deviceid') |
| 37 | + timestamp = self.request.get('timestamp') |
75 | 38 |
|
76 | 39 | self.response.headers['Content-Type'] = 'text/plain' |
77 | | - self.response.write('/metrics - station: {}, kind: {}, id: {}\n'. |
78 | | - format(stationid, smkey.kind(), smkey.id())) |
| 40 | + self.response.write('/metrics - device: {}, timestamp: {}\n'.format(deviceid, timestamp)) |
79 | 41 |
|
80 | 42 |
|
81 | 43 | app = webapp2.WSGIApplication([ |
|
0 commit comments