Skip to content
Snippets Groups Projects
Commit 96c75d8a authored by Nils G.'s avatar Nils G.
Browse files

Add API for /room/status

parent 0da4b944
No related branches found
No related tags found
No related merge requests found
from parameter_util import JSON_BODY, JSON_CONTAINS
from http_util import FAIL, CODE_JSON, CODE_MISSING, CODE_SEMANTIC
from room_util import ROOM_GET
import random
......@@ -23,3 +24,26 @@ def create():
json = {"room_id": room_id, "room_code": room_record.code, "room_pw": room_record.hashcode}
return(response.json(json))
def status():
parameters = JSON_BODY(request)
if parameters == None:
return(FAIL(CODE_JSON))
if not JSON_CONTAINS(parameters, [('room_id', int), ('room_pw', str)]):
return(FAIL(CODE_MISSING))
room_id = parameters['room_id']
room_pw = parameters['room_pw']
room_record = ROOM_GET(room_id, room_pw)
if not room_record:
return(FAIL(CODE_SEMANTIC))
json = {"players": []}
return(response.json(json))
from gluon import *
def ROOM_GET(_id, _password):
room_record = current.db(current.db.Room.id == _id).select().first()
if not room_record:
return(None)
if room_record.hashcode != _password:
return(None)
return(room_record)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment