Receive form data

This commit is contained in:
2025-12-31 15:17:04 +01:00
parent 139b3992d8
commit aeb4bd74d9
3 changed files with 19 additions and 13 deletions

View File

@@ -4,7 +4,7 @@ import os
import cv2
import requests
from dotenv import load_dotenv
from flask import Flask, jsonify
from flask import Flask, jsonify, request
from hardware.light.lora_light_sensor_reader import LoraLightSensorReader
from hardware.rfid.reader import RfidReader
@@ -55,6 +55,8 @@ game_service = GameService()
@app.route("/command/party/start", methods=['POST'])
def start_party():
try:
data = request.get_json()
print(f"Received data : {data}")
print("Party started!")
return jsonify({"status": "ok", "message": "Party started"}), 200
except Exception as ex:
@@ -64,16 +66,8 @@ def start_party():
@app.route("/command/party/play", methods=['POST'])
def make_move():
try:
frame, fen = game_service.make_move()
print(fen)
headers = {'Content-Type': 'image/jpeg'}
body = {'frame': frame, 'fen': fen}
response = requests.post(
"https://192.168.15.125:1880/party/image",
data=body,
headers=headers,
verify=False)
print(response.status_code)
game_service.make_move()
return jsonify({"status": "ok", "message": "Party started"}), 200
except Exception as ex:
print(ex)