Skip to content

Commit

Permalink
Update falcon to version 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescoCeruti committed Oct 25, 2024
1 parent 27527d2 commit f9600d4
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 118 deletions.
15 changes: 8 additions & 7 deletions lisp/plugins/network/api/cues.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import json

import falcon
from falcon import Request, Response

from lisp.cues.cue import CueAction
from lisp.plugins.network.endpoint import EndPoint
Expand All @@ -35,25 +36,25 @@ def resolve_cue(app, cue_id):
class CuesListEndPoint(EndPoint):
UriTemplate = "/cues"

def on_get(self, request, response):
def on_get(self, request: Request, response: Response):
response.status = falcon.HTTP_OK
response.body = json.dumps({"cues": tuple(self.app.cue_model.keys())})
response.text = json.dumps({"cues": tuple(self.app.cue_model.keys())})


class CueEndPoint(EndPoint):
UriTemplate = "/cues/{cue_id}"

def on_get(self, request, response, cue_id):
def on_get(self, request: Request, response: Response, cue_id):
cue = resolve_cue(self.app, cue_id)

response.status = falcon.HTTP_OK
response.body = json.dumps(cue.properties())
response.text = json.dumps(cue.properties())


class CueActionEndPoint(EndPoint):
UriTemplate = "/cues/{cue_id}/action"

def on_post(self, request, response, cue_id):
def on_post(self, request: Request, response: Response, cue_id):
cue = resolve_cue(self.app, cue_id)

try:
Expand All @@ -69,11 +70,11 @@ def on_post(self, request, response, cue_id):
class CueStateEndPoint(EndPoint):
UriTemplate = "/cues/{cue_id}/state"

def on_get(self, request, response, cue_id):
def on_get(self, request: Request, response: Response, cue_id):
cue = resolve_cue(self.app, cue_id)

response.status = falcon.HTTP_OK
response.body = json.dumps(
response.text = json.dumps(
{
"state": cue.state,
"current_time": cue.current_time(),
Expand Down
Loading

0 comments on commit f9600d4

Please sign in to comment.