You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
654 B
23 lines
654 B
from pythonosc.dispatcher import Dispatcher
|
|
from pythonosc.osc_server import BlockingOSCUDPServer
|
|
|
|
import subprocess
|
|
from subprocess import Popen
|
|
|
|
def default_handler(address, *args):
|
|
print(f"DEFAULT {address}: {args}")
|
|
|
|
def run_script(address, *args):
|
|
script_to_run = address.split("/")[-1]
|
|
print(f"Script to run: {script_to_run}")
|
|
Popen(script_to_run,creationflags=subprocess.CREATE_NEW_CONSOLE)
|
|
|
|
dispatcher = Dispatcher()
|
|
dispatcher.map("/script/*", run_script)
|
|
dispatcher.set_default_handler(default_handler)
|
|
|
|
ip = "127.0.0.1"
|
|
port = 1337
|
|
|
|
server = BlockingOSCUDPServer((ip, port), dispatcher)
|
|
server.serve_forever() # Blocks forever |