Skip to content

Commit

Permalink
fixed security issue
Browse files Browse the repository at this point in the history
  • Loading branch information
cheng-chi committed Sep 8, 2022
1 parent 843e2c5 commit 4df1908
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions run_server_pyk4a.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,8 @@
k4a.exposure = 8330

async def exposure_handle(request):
"""
To set manual exposure, use format
<host>:<port>/exposure?shutter_us=8330
To use auto exposure, use format
<host>:<port>/exposure
"""

try:
auto = 'shutter_us' not in request.query
auto = (request.query['auto'] == 'True')
exposure = int(request.query.get('shutter_us', '8330'))
k4a.exposure_mode_auto = auto
if auto:
Expand All @@ -42,10 +35,10 @@ async def exposure_handle(request):
else:
k4a.exposure = exposure

text = f'Success! Auto exposure {auto}, shutter_us {exposure}'
text = f'Success! Auto exposure {auto}, shutt_us {exposure}'
return web.Response(body=text)
except:
text = 'Incorrect format! use format <host>:<port>/exposure?shutter_us=8330'
text = 'Incorrect format! use format <host>:<port>/exposure?auto=False&shutter_us=8330'
return web.Response(body=text)

async def view_handle(request):
Expand Down

0 comments on commit 4df1908

Please sign in to comment.