Skip to content

Commit

Permalink
add endpoint to get template body
Browse files Browse the repository at this point in the history
  • Loading branch information
gtfierro committed Jan 15, 2025
1 parent c2772be commit bc17408
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions buildingmotif/api/views/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,25 @@ def evaluate_bindings(template_id: int) -> flask.Response:
return graph.serialize(format="ttl"), status.HTTP_200_OK


@blueprint.route("/<template_id>/body", methods=(["GET"]))
def get_template_body(template_id: int) -> flask.Response:
"""Get template body.
:param template_id: template id
:type template_id: int
:return: template body
:rtype: flask.Response
"""
try:
template: Template = Template.load(template_id)
except TemplateNotFound:
return {
"message": f"No template with id {template_id}"
}, status.HTTP_404_NOT_FOUND

return template.body.serialize(format="ttl"), status.HTTP_200_OK


def get_bindings(binding_dict) -> Dict[str, Node]:
"""type binding_dict values to nodes
Expand Down

0 comments on commit bc17408

Please sign in to comment.