Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion OSC_REST.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,20 @@ def putRequest(unused_addr, uri, args):
print(str(in_json))
reply = requests.put(uri, json = in_json)
client.send_message("/REST/OSC", reply.text)


#PATCH Request
def patchRequest(unused_addr, uri, args):
print("Received info for PATCH request")
in_json = json.loads(args)
print(str(in_json))
reply = requests.patch(uri, json = in_json)
client.send_message("/REST/OSC", reply.text)

#DELETE Request
def deleteRequest(unused_addr, uri):
print("Received info for DELETE request")
reply = requests.delete(uri)
client.send_message("/REST/OSC", reply.text)

#Main execution script--------------------------------------
if __name__ == "__main__":
Expand Down Expand Up @@ -97,6 +110,8 @@ def putRequest(unused_addr, uri, args):
dispatcher.map("/OSC/REST/GET", getRequest)
dispatcher.map("/OSC/REST/POST", postRequest)
dispatcher.map("/OSC/REST/PUT", putRequest)
dispatcher.map("/OSC/REST/PATCH", patchRequest)
dispatcher.map("/OSC/REST/DELETE", deleteRequest)

#set up server to listen for osc messages
server = osc_server.ThreadingOSCUDPServer((send_ip,receive_port),dispatcher)
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
A simple python application to bridge Open Sound Control (OSC) to REST APIs

## About
REST APIs are a popular method for communicating with web servers and other databases. Often, physical equipment will also (for better or for worse) implement a REST API for its remote interfacing capabilities. Open Sound Control (OSC) is a commonly used protocol in the entertainment technology industry for inter-application communications across LAN. Occasionally, a piece of equipment that would seem suited for a UDP/TCP API will instead implement REST, and hardware / software not suited for web request communications will be unable to integrate those appliances. This application seeks to resolve the issue by allowing the mechanisms of OSC to communicate with web servers via GET, POST, and PUT requests for bridging OSC to REST APIs.
REST APIs are a popular method for communicating with web servers and other databases. Often, physical equipment will also (for better or for worse) implement a REST API for its remote interfacing capabilities. Open Sound Control (OSC) is a commonly used protocol in the entertainment technology industry for inter-application communications across LAN. Occasionally, a piece of equipment that would seem suited for a UDP/TCP API will instead implement REST, and hardware / software not suited for web request communications will be unable to integrate those appliances. This application seeks to resolve the issue by allowing the mechanisms of OSC to communicate with web servers via GET, POST, PUT, PATCH, and DELETE requests for bridging OSC to REST APIs.

## Setup
Launch the application and either select the default networking options or input your own information for the OSC network. Then, send OSC command to the application via the API below. Commands sent to OSC-REST will begin with /OSC and commands sent back from OSC-REST will begin with /REST
Expand All @@ -14,6 +14,10 @@ Launch the application and either select the default networking options or input

/OSC/REST/PUT {string uri, string json} - initiate a PUT request with the provided JSON string passed as the argument. If the server responds, the response will be sent via OSC.

/OSC/REST/PATCH {string uri, string json} - initiate a PATCH request with the provided JSON string passed as the argument. If the server responds, the response will be sent via OSC.

/OSC/REST/DELETE {string uri} - initiate a DELETE request with the server located at the URI string. If the server responds, the response will be sent via OSC.

## Commands to Receive
/REST/OSC {string response} - the response string from the given request

Expand Down