Skip to content
This repository was archived by the owner on Jun 7, 2021. It is now read-only.

Commit 690a5da

Browse files
authored
Support OPTIONS requests. (#66)
1 parent 6b28e32 commit 690a5da

4 files changed

Lines changed: 14 additions & 6 deletions

File tree

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ifaddr>=0.1.0
22
jsonschema==2.6.*; python_version < '3.5'
3-
jsonschema>=3.0.0; python_version >= '3.5'
4-
pyee>=6.0.0
3+
jsonschema>=3.2.0; python_version >= '3.5'
4+
pyee>=7.0.0
55
tornado==5.1.*; python_version < '3.5'
66
tornado>=6.0.0; python_version >= '3.5'
77
zeroconf==0.19.*; python_version == '2.7'

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
requirements = [
1616
'ifaddr>=0.1.0',
17-
'pyee>=6.0.0',
17+
'pyee>=7.0.0',
1818
]
1919

2020
if sys.version_info.major == 2:
@@ -32,14 +32,14 @@
3232
])
3333
else:
3434
requirements.extend([
35-
'jsonschema>=3.0.0',
35+
'jsonschema>=3.2.0',
3636
'tornado>=6.0.0',
3737
'zeroconf>=0.21.0',
3838
])
3939

4040
setup(
4141
name='webthing',
42-
version='0.12.1',
42+
version='0.12.2',
4343
description='HTTP Web Thing implementation',
4444
long_description=long_description,
4545
url='https://github.com/mozilla-iot/webthing-python',

webthing/server.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ def set_default_headers(self, *args, **kwargs):
122122
self.set_header('Access-Control-Allow-Methods',
123123
'GET, HEAD, PUT, POST, DELETE')
124124

125+
def options(self, *args, **kwargs):
126+
"""Handle an OPTIONS request."""
127+
self.set_status(204)
128+
125129

126130
class ThingsHandler(BaseHandler):
127131
"""Handle a request to / when the server manages multiple things."""
@@ -191,6 +195,10 @@ def set_default_headers(self, *args, **kwargs):
191195
self.set_header('Access-Control-Allow-Methods',
192196
'GET, HEAD, PUT, POST, DELETE')
193197

198+
def options(self, *args, **kwargs):
199+
"""Handle an OPTIONS request."""
200+
self.set_status(204)
201+
194202
def get_thing(self, thing_id):
195203
"""
196204
Get the thing this request is for.

webthing/value.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
if sys.version_info.major == 3:
66
from pyee import AsyncIOEventEmitter as EventEmitter
77
else:
8-
from pyee import EventEmitter
8+
from pyee import BaseEventEmitter as EventEmitter
99

1010

1111
class Value(EventEmitter):

0 commit comments

Comments
 (0)