File tree 3 files changed +7
-4
lines changed 3 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ With `python github_adapter.py` you will check for new issues and a POST request
26
26
27
27
You can also use only ` python siren.py [port] ` and make a POST:
28
28
29
- ` http -f POST http://localhost:8080/light actor=my_test duration=3 `
29
+ ` http POST http://localhost:8080/light actor=my_test duration=3 `
30
30
31
31
I manage it with [ supervisord] ( http://supervisord.org/ ) on Raspbian.
32
32
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ def check_and_send_light_request(urgent_ticket):
20
20
# request to beacon light
21
21
logging .info ('New urgent ticket found: {}' .format (urgent_ticket ))
22
22
payload = {'actor' : 'github_adapter' , 'duration' : LIGHT_SECONDS }
23
- requests .post (BASE_URL + '/light' , data = payload )
23
+ requests .post (BASE_URL + '/light' , json = payload )
24
24
25
25
26
26
if __name__ == '__main__' :
Original file line number Diff line number Diff line change 1
1
# -*- coding: utf-8 -*-
2
2
3
+ import json
3
4
import logging
4
5
import sys
5
6
import time
21
22
22
23
class light :
23
24
def POST (self ):
24
- i = web .input ()
25
- turn_on_the_light (i .duration , i .actor )
25
+ data = json .loads (web .data () or '{}' )
26
+ if not 'duration' in data or not 'actor' in data :
27
+ return web .badrequest ()
28
+ turn_on_the_light (data ['duration' ] or 1 , data ['actor' ])
26
29
return web .nocontent ()
27
30
28
31
You can’t perform that action at this time.
0 commit comments