fix: allow tauri app to interface with flask backend
This commit is contained in:
parent
fc82783845
commit
7e295a3a00
4 changed files with 20 additions and 3 deletions
|
@ -6,6 +6,7 @@ import signal
|
||||||
import sys
|
import sys
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
from flask_cors import CORS
|
||||||
|
|
||||||
import ntcore
|
import ntcore
|
||||||
import waitress
|
import waitress
|
||||||
|
@ -25,7 +26,8 @@ signal.signal(signal.SIGINT, signal_handler)
|
||||||
|
|
||||||
# initialize flask app and socketio
|
# initialize flask app and socketio
|
||||||
app = Flask(__name__, static_folder="dist", static_url_path="/")
|
app = Flask(__name__, static_folder="dist", static_url_path="/")
|
||||||
socketio = SocketIO(app)
|
CORS(app)
|
||||||
|
socketio = SocketIO(app, cors_allowed_origins="*")
|
||||||
|
|
||||||
inst = ntcore.NetworkTableInstance.getDefault()
|
inst = ntcore.NetworkTableInstance.getDefault()
|
||||||
table = inst.getTable("SmartDashboard")
|
table = inst.getTable("SmartDashboard")
|
||||||
|
|
|
@ -25,7 +25,7 @@ export const initializeTelemetry = (
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const socket = io()
|
const socket = io('localhost:1280')
|
||||||
socket.on('connect', () => {
|
socket.on('connect', () => {
|
||||||
console.log('Socket-IO connected!')
|
console.log('Socket-IO connected!')
|
||||||
socket.emit('subscribe', topics)
|
socket.emit('subscribe', topics)
|
||||||
|
|
16
poetry.lock
generated
16
poetry.lock
generated
|
@ -107,6 +107,20 @@ Werkzeug = ">=3.0.0"
|
||||||
async = ["asgiref (>=3.2)"]
|
async = ["asgiref (>=3.2)"]
|
||||||
dotenv = ["python-dotenv"]
|
dotenv = ["python-dotenv"]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "flask-cors"
|
||||||
|
version = "4.0.0"
|
||||||
|
description = "A Flask extension adding a decorator for CORS support"
|
||||||
|
optional = false
|
||||||
|
python-versions = "*"
|
||||||
|
files = [
|
||||||
|
{file = "Flask-Cors-4.0.0.tar.gz", hash = "sha256:f268522fcb2f73e2ecdde1ef45e2fd5c71cc48fe03cffb4b441c6d1b40684eb0"},
|
||||||
|
{file = "Flask_Cors-4.0.0-py2.py3-none-any.whl", hash = "sha256:bc3492bfd6368d27cfe79c7821df5a8a319e1a6d5eab277a3794be19bdc51783"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[package.dependencies]
|
||||||
|
Flask = ">=0.9"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flask-socketio"
|
name = "flask-socketio"
|
||||||
version = "5.3.6"
|
version = "5.3.6"
|
||||||
|
@ -556,4 +570,4 @@ h11 = ">=0.9.0,<1"
|
||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "2.0"
|
lock-version = "2.0"
|
||||||
python-versions = "^3.12"
|
python-versions = "^3.12"
|
||||||
content-hash = "3afde2c87621fc59faa4e33e0384a7dd132ac8b1471c1fa3e62dadcce0660dde"
|
content-hash = "231c9d57b5d81f58f755c4564ca2de3e2b1533ffa560f9cb6d12be3c13130260"
|
||||||
|
|
|
@ -14,6 +14,7 @@ flask-socketio = '^5.3.6'
|
||||||
eventlet = '^0.34.3'
|
eventlet = '^0.34.3'
|
||||||
flaskwebgui = '^1.0.8'
|
flaskwebgui = '^1.0.8'
|
||||||
waitress = '^2.1.2'
|
waitress = '^2.1.2'
|
||||||
|
flask-cors = "^4.0.0"
|
||||||
|
|
||||||
[tool.poetry.group.dev.dependencies]
|
[tool.poetry.group.dev.dependencies]
|
||||||
ruff = '^0.2.2'
|
ruff = '^0.2.2'
|
||||||
|
|
Loading…
Reference in a new issue