def transistor():
transistor_name = request.forms.get('transistorname')
state = request.forms.get('state')
token = request.forms.get('token')
valid_token = verify_auth_token(token)
if valid_token == True:
if transistor_name == 'transistor1' or transistor_name == 'transistor2' or transistor_name == 'transistor3':
if state == "high":
print "aqui"
high_rele(dic_pins[transistor_name],"b")
print dic_pins[transistor_name]
theBody = json.dumps({'200': transistor_name}) # you seem to want a JSON response
return HTTPResponse(status=200, body=theBody)
elif state == "low":
low_rele(dic_pins[transistor_name],"b")
theBody = json.dumps({'200': transistor_name}) # you seem to want a JSON response
return HTTPResponse(status=200, body=theBody)
else:
theBody = json.dumps({'412': "Precondition Failed"}) # you seem to want a JSON response
return HTTPResponse(status=412, body=theBody)
else:
theBody = json.dumps({'412': "Precondition Failed"}) # you seem to want a JSON response
return HTTPResponse(status=412, body=theBody)
else:
theBody = json.dumps({'401': 'Unauthorized'}) # you seem to want a JSON response
return HTTPResponse(status=401, body=theBody)
评论列表
文章目录