implement api route /getReaction

This commit is contained in:
Thomas Rubini 2023-03-26 16:12:10 +02:00
parent ef5ed73c9e
commit daeea9cfd7
No known key found for this signature in database
GPG Key ID: C7D287C8C1CAC373

View File

@ -1,7 +1,11 @@
import json
import json
import flask
import io
import flask
from sqlalchemy import select
from truthinquiry.ext.database.models import *
from truthinquiry.ext.database.fsa import db
from truthinquiry.ext.discord_bot import discord_bot
from truthinquiry.ext.socketio import socket_io
from truthinquiry.logic import game_logic
@ -154,6 +158,20 @@ def get_npc_reaction():
'Content-Disposition', 'attachment', filename='reaction.png')
return response
@routes_api.route("/getReaction", methods=["GET", "POST"])
def get_reaction():
input_uuid = flask.request.values.get("uuid")
results = db.session.execute(select(Reaction).where(Reaction.REACTION_UUID==uuid.UUID(input_uuid)))
row = results.first()
if row == None:
return {"error": 1, "msg": "No such reaction"}
reaction_obj = row[0]
return flask.send_file(io.BytesIO(reaction_obj.IMG), mimetype='image/png')
@routes_api.route("/gameProgress", methods=["GET", "POST"])
def game_progress():