I am trying to run a simple python script inside the OAK4D Pro camera.
from flask import Flask, request, jsonify
app = Flask(__name__)
# Global variable to store the value
shared_variable = None
@app.route('/update', methods=['POST'])
def update_variable():
global shared_variable
data = request.json
if 'value' in data:
shared_variable = data['value']
return jsonify({"message": "Variable updated successfully", "new_value": shared_variable}), 200
else:
return jsonify({"error": "Missing 'value' in request"}), 400
@app.route('/get', methods=['GET'])
def get_variable():
return jsonify({"shared_variable": shared_variable}), 200
def get_shared_variable():
return shared_variable
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8080)
I set the static IP and opened the port using:
iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
When I adb shell into the camera and run the python program, the connection times out when I try to connect from an external machine. Is there something I am missing?
Thanks,
Jimit