From b972f97d01d7072aae53ac458a2642990ff90e83 Mon Sep 17 00:00:00 2001 From: amit-62 Date: Thu, 16 Jun 2022 22:44:56 +0530 Subject: [PATCH 1/8] FRI added --- fri/example.py | 1 + fri/friApi.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ fri/test.py | 15 +++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 fri/example.py create mode 100644 fri/friApi.py create mode 100644 fri/test.py diff --git a/fri/example.py b/fri/example.py new file mode 100644 index 0000000..05e2ce0 --- /dev/null +++ b/fri/example.py @@ -0,0 +1 @@ +print('concore') \ No newline at end of file diff --git a/fri/friApi.py b/fri/friApi.py new file mode 100644 index 0000000..8f9a891 --- /dev/null +++ b/fri/friApi.py @@ -0,0 +1,48 @@ +from flask import Flask, request, jsonify +from werkzeug.utils import secure_filename +import os + +# location of folder to store received file +UPLOAD_FOLDER = "./received_files" + +if not os.path.exists(UPLOAD_FOLDER): + os.makedirs(UPLOAD_FOLDER) + +app = Flask(__name__) +app.secret_key = "secret key" +app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER + +@app.route('/upload_files', methods=['POST']) +def upload_file(): + if 'files[]' not in request.files: + resp = jsonify({'message' : 'No file in the request'}) + resp.status_code = 400 + return resp + + files = request.files.getlist('files[]') + + errors = {} + success = False + + for file in files: + if file: + filename = secure_filename(file.filename) + file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) + success = True + + if success and errors: + errors['message'] = 'File(s) successfully uploaded' + resp = jsonify(errors) + resp.status_code = 500 + return resp + if success: + resp = jsonify({'message' : 'Files successfully uploaded'}) + resp.status_code = 201 + return resp + else: + resp = jsonify(errors) + resp.status_code = 500 + return resp + +if __name__ == "__main__": + app.run(debug=True) diff --git a/fri/test.py b/fri/test.py new file mode 100644 index 0000000..af648f5 --- /dev/null +++ b/fri/test.py @@ -0,0 +1,15 @@ +#This file is just to check if friApi.py works perfectly. +import requests + +url = "http://127.0.0.1:5000/upload_files" + +payload={} +# replace as example.py with target file name and it must already exist in given Dir. +files=[ + ('files[]',('example.py',open('/Users/ASUS/concore/fri/example.py','rb'),'application/octet-stream')), + ] +headers = {} + +response = requests.request("POST", url, headers=headers, data=payload, files=files) + +print(response.text) From dd48dbce2fb3615e5d2102890b6eedca38f1efdf Mon Sep 17 00:00:00 2001 From: Amit Kumar <76881647+amit-62@users.noreply.github.com> Date: Thu, 16 Jun 2022 22:58:49 +0530 Subject: [PATCH 2/8] Delete fri directory --- fri/example.py | 1 - fri/friApi.py | 48 ------------------------------------------------ fri/test.py | 15 --------------- 3 files changed, 64 deletions(-) delete mode 100644 fri/example.py delete mode 100644 fri/friApi.py delete mode 100644 fri/test.py diff --git a/fri/example.py b/fri/example.py deleted file mode 100644 index 05e2ce0..0000000 --- a/fri/example.py +++ /dev/null @@ -1 +0,0 @@ -print('concore') \ No newline at end of file diff --git a/fri/friApi.py b/fri/friApi.py deleted file mode 100644 index 8f9a891..0000000 --- a/fri/friApi.py +++ /dev/null @@ -1,48 +0,0 @@ -from flask import Flask, request, jsonify -from werkzeug.utils import secure_filename -import os - -# location of folder to store received file -UPLOAD_FOLDER = "./received_files" - -if not os.path.exists(UPLOAD_FOLDER): - os.makedirs(UPLOAD_FOLDER) - -app = Flask(__name__) -app.secret_key = "secret key" -app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER - -@app.route('/upload_files', methods=['POST']) -def upload_file(): - if 'files[]' not in request.files: - resp = jsonify({'message' : 'No file in the request'}) - resp.status_code = 400 - return resp - - files = request.files.getlist('files[]') - - errors = {} - success = False - - for file in files: - if file: - filename = secure_filename(file.filename) - file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) - success = True - - if success and errors: - errors['message'] = 'File(s) successfully uploaded' - resp = jsonify(errors) - resp.status_code = 500 - return resp - if success: - resp = jsonify({'message' : 'Files successfully uploaded'}) - resp.status_code = 201 - return resp - else: - resp = jsonify(errors) - resp.status_code = 500 - return resp - -if __name__ == "__main__": - app.run(debug=True) diff --git a/fri/test.py b/fri/test.py deleted file mode 100644 index af648f5..0000000 --- a/fri/test.py +++ /dev/null @@ -1,15 +0,0 @@ -#This file is just to check if friApi.py works perfectly. -import requests - -url = "http://127.0.0.1:5000/upload_files" - -payload={} -# replace as example.py with target file name and it must already exist in given Dir. -files=[ - ('files[]',('example.py',open('/Users/ASUS/concore/fri/example.py','rb'),'application/octet-stream')), - ] -headers = {} - -response = requests.request("POST", url, headers=headers, data=payload, files=files) - -print(response.text) From cbe24cc64742b7eab1a0acef0d8228de38eeac1a Mon Sep 17 00:00:00 2001 From: amit-62 Date: Thu, 16 Jun 2022 23:17:46 +0530 Subject: [PATCH 3/8] FRI added --- fri/example.py | 1 + fri/friApi.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ fri/test.py | 15 +++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 fri/example.py create mode 100644 fri/friApi.py create mode 100644 fri/test.py diff --git a/fri/example.py b/fri/example.py new file mode 100644 index 0000000..05e2ce0 --- /dev/null +++ b/fri/example.py @@ -0,0 +1 @@ +print('concore') \ No newline at end of file diff --git a/fri/friApi.py b/fri/friApi.py new file mode 100644 index 0000000..8f9a891 --- /dev/null +++ b/fri/friApi.py @@ -0,0 +1,48 @@ +from flask import Flask, request, jsonify +from werkzeug.utils import secure_filename +import os + +# location of folder to store received file +UPLOAD_FOLDER = "./received_files" + +if not os.path.exists(UPLOAD_FOLDER): + os.makedirs(UPLOAD_FOLDER) + +app = Flask(__name__) +app.secret_key = "secret key" +app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER + +@app.route('/upload_files', methods=['POST']) +def upload_file(): + if 'files[]' not in request.files: + resp = jsonify({'message' : 'No file in the request'}) + resp.status_code = 400 + return resp + + files = request.files.getlist('files[]') + + errors = {} + success = False + + for file in files: + if file: + filename = secure_filename(file.filename) + file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) + success = True + + if success and errors: + errors['message'] = 'File(s) successfully uploaded' + resp = jsonify(errors) + resp.status_code = 500 + return resp + if success: + resp = jsonify({'message' : 'Files successfully uploaded'}) + resp.status_code = 201 + return resp + else: + resp = jsonify(errors) + resp.status_code = 500 + return resp + +if __name__ == "__main__": + app.run(debug=True) diff --git a/fri/test.py b/fri/test.py new file mode 100644 index 0000000..af648f5 --- /dev/null +++ b/fri/test.py @@ -0,0 +1,15 @@ +#This file is just to check if friApi.py works perfectly. +import requests + +url = "http://127.0.0.1:5000/upload_files" + +payload={} +# replace as example.py with target file name and it must already exist in given Dir. +files=[ + ('files[]',('example.py',open('/Users/ASUS/concore/fri/example.py','rb'),'application/octet-stream')), + ] +headers = {} + +response = requests.request("POST", url, headers=headers, data=payload, files=files) + +print(response.text) From 1bdb673fd3308896ac8731f961f34fb63e09e869 Mon Sep 17 00:00:00 2001 From: Amit Kumar <76881647+amit-62@users.noreply.github.com> Date: Wed, 22 Jun 2022 01:23:07 +0530 Subject: [PATCH 4/8] Delete fri directory --- fri/example.py | 1 - fri/friApi.py | 48 ------------------------------------------------ fri/test.py | 15 --------------- 3 files changed, 64 deletions(-) delete mode 100644 fri/example.py delete mode 100644 fri/friApi.py delete mode 100644 fri/test.py diff --git a/fri/example.py b/fri/example.py deleted file mode 100644 index 05e2ce0..0000000 --- a/fri/example.py +++ /dev/null @@ -1 +0,0 @@ -print('concore') \ No newline at end of file diff --git a/fri/friApi.py b/fri/friApi.py deleted file mode 100644 index 8f9a891..0000000 --- a/fri/friApi.py +++ /dev/null @@ -1,48 +0,0 @@ -from flask import Flask, request, jsonify -from werkzeug.utils import secure_filename -import os - -# location of folder to store received file -UPLOAD_FOLDER = "./received_files" - -if not os.path.exists(UPLOAD_FOLDER): - os.makedirs(UPLOAD_FOLDER) - -app = Flask(__name__) -app.secret_key = "secret key" -app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER - -@app.route('/upload_files', methods=['POST']) -def upload_file(): - if 'files[]' not in request.files: - resp = jsonify({'message' : 'No file in the request'}) - resp.status_code = 400 - return resp - - files = request.files.getlist('files[]') - - errors = {} - success = False - - for file in files: - if file: - filename = secure_filename(file.filename) - file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) - success = True - - if success and errors: - errors['message'] = 'File(s) successfully uploaded' - resp = jsonify(errors) - resp.status_code = 500 - return resp - if success: - resp = jsonify({'message' : 'Files successfully uploaded'}) - resp.status_code = 201 - return resp - else: - resp = jsonify(errors) - resp.status_code = 500 - return resp - -if __name__ == "__main__": - app.run(debug=True) diff --git a/fri/test.py b/fri/test.py deleted file mode 100644 index af648f5..0000000 --- a/fri/test.py +++ /dev/null @@ -1,15 +0,0 @@ -#This file is just to check if friApi.py works perfectly. -import requests - -url = "http://127.0.0.1:5000/upload_files" - -payload={} -# replace as example.py with target file name and it must already exist in given Dir. -files=[ - ('files[]',('example.py',open('/Users/ASUS/concore/fri/example.py','rb'),'application/octet-stream')), - ] -headers = {} - -response = requests.request("POST", url, headers=headers, data=payload, files=files) - -print(response.text) From a0b4ba83b8a8225bc1e4a219eee8e8f01d6a9138 Mon Sep 17 00:00:00 2001 From: amit-62 Date: Wed, 22 Jun 2022 01:31:51 +0530 Subject: [PATCH 5/8] fri added --- fri/Dockerfile | 10 ++++++++ fri/example.py | 1 + fri/main.py | 52 +++++++++++++++++++++++++++++++++++++++++ fri/requirements.txt | 2 ++ fri/templates/home.html | 12 ++++++++++ fri/test.py | 13 +++++++++++ 6 files changed, 90 insertions(+) create mode 100644 fri/Dockerfile create mode 100644 fri/example.py create mode 100644 fri/main.py create mode 100644 fri/requirements.txt create mode 100644 fri/templates/home.html create mode 100644 fri/test.py diff --git a/fri/Dockerfile b/fri/Dockerfile new file mode 100644 index 0000000..02eedf7 --- /dev/null +++ b/fri/Dockerfile @@ -0,0 +1,10 @@ +FROM centos/python-36-centos7 + +WORKDIR /fri +COPY . /fri + +COPY requirements.txt /fri/requirements.txt +RUN pip install -r /fri/requirements.txt + + +CMD ["gunicorn", "-w", "4", "--bind", "0.0.0.0:8080", "main:app"] diff --git a/fri/example.py b/fri/example.py new file mode 100644 index 0000000..bff2a13 --- /dev/null +++ b/fri/example.py @@ -0,0 +1 @@ +print("amit") \ No newline at end of file diff --git a/fri/main.py b/fri/main.py new file mode 100644 index 0000000..0ac2108 --- /dev/null +++ b/fri/main.py @@ -0,0 +1,52 @@ +from flask import Flask, request, jsonify, render_template +from werkzeug.utils import secure_filename +import os + + +UPLOAD_FOLDER = "./uploaded_files" + +if not os.path.exists(UPLOAD_FOLDER): + os.makedirs(UPLOAD_FOLDER) + +app = Flask(__name__) +app.secret_key = "secret key" +app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER + +@app.route('/') +def hello_world(): + return render_template('home.html') + +@app.route('/multiple-files-upload', methods=['POST']) +def upload_file(): + if 'files[]' not in request.files: + resp = jsonify({'message' : 'No file in the request'}) + resp.status_code = 400 + return resp + + files = request.files.getlist('files[]') + + errors = {} + success = False + + for file in files: + if file: + filename = secure_filename(file.filename) + file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) + success = True + + if success and errors: + errors['message'] = 'File(s) successfully uploaded' + resp = jsonify(errors) + resp.status_code = 500 + return resp + if success: + resp = jsonify({'message' : 'Files successfully uploaded'}) + resp.status_code = 201 + return resp + else: + resp = jsonify(errors) + resp.status_code = 500 + return resp + +if __name__ == "__main__": + app.run(host="0.0.0.0") diff --git a/fri/requirements.txt b/fri/requirements.txt new file mode 100644 index 0000000..82d3ede --- /dev/null +++ b/fri/requirements.txt @@ -0,0 +1,2 @@ +Flask +gunicorn==20.1.0 \ No newline at end of file diff --git a/fri/templates/home.html b/fri/templates/home.html new file mode 100644 index 0000000..6b87469 --- /dev/null +++ b/fri/templates/home.html @@ -0,0 +1,12 @@ + + + + + + + Document + + +

Home page

+ + \ No newline at end of file diff --git a/fri/test.py b/fri/test.py new file mode 100644 index 0000000..6852bc1 --- /dev/null +++ b/fri/test.py @@ -0,0 +1,13 @@ +import requests + +url = "http://127.0.0.1:5000/multiple-files-upload" + +payload={} +files=[ + ('files[]',('example.py',open('/home/amit/Desktop/concore/flaskApi/example.py','rb'),'application/octet-stream')) +] +headers = {} + +response = requests.request("POST", url, headers=headers, data=payload, files=files) + +print(response.text) From 54d73c7fbb69beb676adc1f5b63873a1c2a844a0 Mon Sep 17 00:00:00 2001 From: amit-62 Date: Thu, 23 Jun 2022 01:27:58 +0530 Subject: [PATCH 6/8] Dockerfile changed --- fri/Dockerfile | 17 ++++++++--------- fri/{ => server}/main.py | 3 --- fri/templates/home.html | 12 ------------ 3 files changed, 8 insertions(+), 24 deletions(-) rename fri/{ => server}/main.py (90%) delete mode 100644 fri/templates/home.html diff --git a/fri/Dockerfile b/fri/Dockerfile index 02eedf7..ad37113 100644 --- a/fri/Dockerfile +++ b/fri/Dockerfile @@ -1,10 +1,9 @@ FROM centos/python-36-centos7 - -WORKDIR /fri -COPY . /fri - -COPY requirements.txt /fri/requirements.txt -RUN pip install -r /fri/requirements.txt - - -CMD ["gunicorn", "-w", "4", "--bind", "0.0.0.0:8080", "main:app"] +COPY requirements.txt /tmp/requirements.txt +RUN pip install -r /tmp/requirements.txt +WORKDIR /fri +COPY server /fri +USER root +RUN useradd fri && chown -R fri /fri +USER fri +CMD ["gunicorn", "--timeout=180", "--workers=4", "--bind=0.0.0.0:8080", "--access-logfile=-", "main:app"] \ No newline at end of file diff --git a/fri/main.py b/fri/server/main.py similarity index 90% rename from fri/main.py rename to fri/server/main.py index 0ac2108..57e179d 100644 --- a/fri/main.py +++ b/fri/server/main.py @@ -12,9 +12,6 @@ app.secret_key = "secret key" app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER -@app.route('/') -def hello_world(): - return render_template('home.html') @app.route('/multiple-files-upload', methods=['POST']) def upload_file(): diff --git a/fri/templates/home.html b/fri/templates/home.html deleted file mode 100644 index 6b87469..0000000 --- a/fri/templates/home.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - Document - - -

Home page

- - \ No newline at end of file From 55e97c7a1dcc2eca0df2514bf3c2562bcff56b3f Mon Sep 17 00:00:00 2001 From: amit-62 Date: Thu, 23 Jun 2022 23:38:28 +0530 Subject: [PATCH 7/8] FRI Updated --- fri/README.md | 133 ++++++++++++++++++++++++++++++++++++++++++ fri/service_config.sh | 22 +++++++ 2 files changed, 155 insertions(+) create mode 100644 fri/README.md create mode 100644 fri/service_config.sh diff --git a/fri/README.md b/fri/README.md new file mode 100644 index 0000000..e0bae61 --- /dev/null +++ b/fri/README.md @@ -0,0 +1,133 @@ +# The Control-Core FRI for Closed-Loop Neuromodulation Control Systems + +The Control-Core File Receiving Interface (FRI) is built with is Python-3.10. It is the core component that makes the distributed executions a reality in the Control-Core framework. + + +# Building FRI Container + +Connect to the Server VM, assuming x.x.x.x to be the IP address of your server. +```` +$ ssh -i "controlcore.pem" ubuntu@x.x.x.x +```` +Perform Git clone if this is the first time you are configuring the Server +```` +$ git clone git@github.com/ControlCore-Project/concore.git +```` + +First build the Docker Container of the FRI. +```` +$ git pull + +$ sudo docker build -t fri . +```` + +# Running Control-Core FRI with Kong as containers + +If you are already running FRI, make sure to stop and clear existing FRI container as it is likely conflict with the port. If there is Kong gateway running in default ports, stop and clear it too. +```` +$ docker stop fri +$ docker rm fri +$ docker stop kong +$ docker rm kong +```` + +Start and configure Cassandra container for Kong API. +```` +$ docker run -d --name kong-database \ + -p 9042:9042 \ + cassandra:3 + + +$ docker run --rm \ + --link kong-database:kong-database \ + -e "KONG_DATABASE=cassandra" \ + -e "KONG_PG_HOST=kong-database" \ + -e "KONG_PG_USER=kong" \ + -e "KONG_PG_PASSWORD=kong" \ + -e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" \ + kong kong migrations bootstrap +```` + +Start Kong +```` +$ docker run -d --name kong \ + --link kong-database:kong-database \ + -e "KONG_DATABASE=cassandra" \ + -e "KONG_PG_HOST=kong-database" \ + -e "KONG_PG_PASSWORD=kong" \ + -e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" \ + -e "KONG_PROXY_ACCESS_LOG=/dev/stdout" \ + -e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" \ + -e "KONG_PROXY_ERROR_LOG=/dev/stderr" \ + -e "KONG_ADMIN_ERROR_LOG=/dev/stderr" \ + -e "KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl" \ + -p 80:8000 \ + -p 8443:8443 \ + -p 8001:8001 \ + -p 8444:8444 \ + kong +```` + +Start FRI container +```` +$ nohup sudo docker run --name fri -p 8090:8081 fri > controlcore.out & +```` + +Delete if there is a previously configured Kong service. If not, skip this step. First you need to find the ID-VALUE for the route with a GET command before deleting the route and service. +```` +$ curl -X GET "http://localhost:8001/services/fri/routes" +```` +Use the ID output from above to issue the delete command as below (issue this only if you have a previous conflicting service definiton in kong. Otherwise, skip this step): +```` +$ curl -X DELETE "http://localhost:8001/services/fri/routes/ID-VALUE" + +$ curl -X DELETE "http://localhost:8001/services/fri/" +```` + +Define Kong Service and Route. + +First Configure a Kong service, replacing the variable "private-ip" with the private IP address of your server below. +```` +$ curl -i -X POST --url http://localhost:8001/services/ --data 'name=fri' --data 'url=http://private-ip:8090' +```` +Then configure route to the service +```` +$ curl -i -X POST --url http://localhost:8001/services/fri/routes --data 'paths=/' +```` + +Now, controlcore.org is routed through the Kong APIs. + + +# Troubleshooting the FRI + +Connect to the Server VM +```` +$ ssh -i "controlcore.pem" ubuntu@x.x.x.x +```` +Check the Server logs. +```` +$ tail -f controlcore.out +```` +or +```` +$ sudo docker logs fri -f +```` +Find the FRI docker container +```` +$ sudo docker ps +```` +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +dfdd3b3d3308 fri "python main.py" 38 minutes ago Up 38 minutes 0.0.0.0:80->80/tcp fri + +Access the container +```` +$ sudo docker exec -it dfdd /bin/bash +```` + + + +# Citing the CONTROL-CORE FRI + +If you use the CONTROL-CORE FRI in your research, please cite the below paper: + +* Kathiravelu, P., Arnold, M., Fleischer, J., Yao, Y., Awasthi, S., Goel, A. K., Branen, A., Sarikhani, P., Kumar, G., Kothare, M. V., and Mahmoudi, B. **CONTROL-CORE: A Framework for Simulation and Design of Closed-Loop Peripheral Neuromodulation Control Systems**. In IEEE Access. March 2022. https://doi.org/10.1109/ACCESS.2022.3161471 diff --git a/fri/service_config.sh b/fri/service_config.sh new file mode 100644 index 0000000..7301bd5 --- /dev/null +++ b/fri/service_config.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +SERVICES=('init' 'ctl' 'pm' 'cleanup') +for service in "${SERVICES[@]}" +do + name="name="$service + path="paths=/"$service + service_path="url=http://private-ip:8090/"$service + route_path="http://localhost:8001/services/"$service"/routes" + plugin_path="http://localhost:8001/services/"$service"/plugins" + echo "Name is, $name" + echo "Path is, $path" + echo "Service path is, $service_path" + echo "Route path is, $route_path" + echo "Plugin path is, $plugin_path" + echo "Creating Service, $service..." + curl -i -X POST --url http://localhost:8001/services/ --data $name --data $service_path + echo "Creating route for $service..." + curl -i -X POST --url $route_path --data $path + echo "Creating apikey-based authentication for $service..." + curl -X POST $plugin_path --data "name=key-auth" --data "config.key_names=apikey" +done \ No newline at end of file From 9c8e23a680dca8f8bc2393d88ad7f337c6e17a33 Mon Sep 17 00:00:00 2001 From: amit-62 Date: Fri, 24 Jun 2022 00:20:08 +0530 Subject: [PATCH 8/8] FRI updated --- fri/service_config.sh | 2 +- fri/test.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/fri/service_config.sh b/fri/service_config.sh index 7301bd5..c41f37e 100644 --- a/fri/service_config.sh +++ b/fri/service_config.sh @@ -1,6 +1,6 @@ #!/bin/bash -SERVICES=('init' 'ctl' 'pm' 'cleanup') +SERVICES=('upload_file' 'execute') for service in "${SERVICES[@]}" do name="name="$service diff --git a/fri/test.py b/fri/test.py index 6852bc1..aabc5ac 100644 --- a/fri/test.py +++ b/fri/test.py @@ -1,10 +1,13 @@ import requests +import os url = "http://127.0.0.1:5000/multiple-files-upload" +path = os.path.abspath("example.py") + payload={} files=[ - ('files[]',('example.py',open('/home/amit/Desktop/concore/flaskApi/example.py','rb'),'application/octet-stream')) + ('files[]',('example.py',open( path,'rb'),'application/octet-stream')) ] headers = {}