Skip to content
Jack Brookes edited this page Jun 7, 2021 · 9 revisions

post

As of UXF 2.2.0, you can enable the HTTP POST Data Handler in the Data Handling settings in the Session component. This data handler sends POST requests to a URL, with a file path and data (formatted as a string). To get this to work, you need a HTTP server (e.g. written in PHP, Python, etc) that accepts post requests and does something with the data (e.g. writes to a file). The server needs to:

  • Accept a POST request.
  • Handle the form provided in the request. This data handler by default sends the data (formatted as a string) with the data key and the desired filename with the filename key.
  • For WebGL builds, due to security restrictions, the server must be authorised for Cross Origin Resource Sharing (CORS).
  • Optionally it can support Basic HTTP authentication.
  • For security, you should be using HTTPS.

A sample server has been written in Python using Flask. This does the bare minimum, simply writing the data to a file, preserving the folder structure of the file output. Use it, or configure it for your own needs.

Link to Flask web server sample

Install requirements:

pip install Flask Flask-HTTPAuth Flask-CORS

The server can run locally (python webserver_example.py), and then you can configure the data handler so that the URL points to the local address (i.e. http://127.0.0.1:5000/form).

When running on your server you should use python webserver_example.py --host=0.0.0.0, then in Unity you can enter the public IP, or domain name, as the address (e.g. https://123.456.78.910/form).

You can configure the Data Handler using the inspector to enter your URL, and optional username and password:

image

๐Ÿง  Core topics

โ“ More help


๐Ÿ‘ฉโ€๐Ÿ’ป Programming reference

Unit tests

Clone this wiki locally