aboutsummaryrefslogtreecommitdiffstats
path: root/Web/PI/PI.py
diff options
context:
space:
mode:
authorMatt Strapp <matt@mattstrapp.net>2022-02-15 09:26:36 -0600
committerMatt Strapp <matt@mattstrapp.net>2022-02-15 09:26:36 -0600
commit5cbc879c60b3bafe29e8f07f82e2f34b55d81a48 (patch)
treedd575c40e1f704c18912e90b5d0041074722173c /Web/PI/PI.py
parentMake HTTP link not wrong (diff)
downloadee4511w-5cbc879c60b3bafe29e8f07f82e2f34b55d81a48.tar
ee4511w-5cbc879c60b3bafe29e8f07f82e2f34b55d81a48.tar.gz
ee4511w-5cbc879c60b3bafe29e8f07f82e2f34b55d81a48.tar.bz2
ee4511w-5cbc879c60b3bafe29e8f07f82e2f34b55d81a48.tar.lz
ee4511w-5cbc879c60b3bafe29e8f07f82e2f34b55d81a48.tar.xz
ee4511w-5cbc879c60b3bafe29e8f07f82e2f34b55d81a48.tar.zst
ee4511w-5cbc879c60b3bafe29e8f07f82e2f34b55d81a48.zip
Use newer web interface
Diffstat (limited to 'Web/PI/PI.py')
-rw-r--r--Web/PI/PI.py48
1 files changed, 0 insertions, 48 deletions
diff --git a/Web/PI/PI.py b/Web/PI/PI.py
deleted file mode 100644
index a6a597b..0000000
--- a/Web/PI/PI.py
+++ /dev/null
@@ -1,48 +0,0 @@
-#handle a POST request
-from flask import Flask, render_template, request, url_for, jsonify
-import subprocess
-import os
-app = Flask(__name__)
-
-UPLOAD_DESTINATION = "Uploads/"
-
-RESULTS_DESTINATION = "Results/"
-
-@app.route('/')
-def home():
- return "ANDI'S PIE"
-
-@app.route('/tests/endpoint', methods=['POST'])
-def my_test_endpoint():
- # Receive post
- input_json = request.get_json(force=True)
-
- # Put file content into a file caled upload.py
- filename=input_json['filename'].encode("ascii")
- file_content=input_json['file_content'].encode("ascii")
- upload = open(UPLOAD_DESTINATION + filename, "w")
- upload.write(file_content)
- upload.close()
-
- # Run python script
- subprocess.call(["python", UPLOAD_DESTINATION + filename])
-
- # Get results file
- results_filename = filename.split(".")[0]
- results_filename = results_filename + "_results.csv"
- with open(RESULTS_DESTINATION + results_filename, 'r') as results:
- results_content = results.read()
- results.close()
-
- # Remove test file and results file now that were done with them
- os.remove(UPLOAD_DESTINATION + filename)
- os.remove(RESULTS_DESTINATION + results_filename)
-
- # Return results file content
- dictToReturn = {'results_filename':results_filename, 'results_content':results_content}
- return jsonify(dictToReturn)
-
-if __name__ == '__main__':
- app.run(host="localhost", port=8000)
- # UNCOMMENT IF RUNNING PI.PI ON PI
- #app.run(host="192.168.1.10", port=8000)