From 5cbc879c60b3bafe29e8f07f82e2f34b55d81a48 Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Tue, 15 Feb 2022 09:26:36 -0600 Subject: Use newer web interface --- Web/Server/Results/PLACEHOLDER | 0 Web/Server/Results/results.csv | 2 - Web/Server/Server.py | 83 --------------------------------------- Web/Server/static/Server.css | 64 ------------------------------ Web/Server/static/Server.js | 19 --------- Web/Server/templates/base.html | 48 ---------------------- Web/Server/templates/index.html | 26 ------------ Web/Server/templates/results.html | 13 ------ 8 files changed, 255 deletions(-) delete mode 100644 Web/Server/Results/PLACEHOLDER delete mode 100644 Web/Server/Results/results.csv delete mode 100644 Web/Server/Server.py delete mode 100644 Web/Server/static/Server.css delete mode 100644 Web/Server/static/Server.js delete mode 100644 Web/Server/templates/base.html delete mode 100644 Web/Server/templates/index.html delete mode 100644 Web/Server/templates/results.html (limited to 'Web/Server') diff --git a/Web/Server/Results/PLACEHOLDER b/Web/Server/Results/PLACEHOLDER deleted file mode 100644 index e69de29..0000000 diff --git a/Web/Server/Results/results.csv b/Web/Server/Results/results.csv deleted file mode 100644 index 82b0137..0000000 --- a/Web/Server/Results/results.csv +++ /dev/null @@ -1,2 +0,0 @@ -THIS IS RESULTS TEXT -Current Time = 10:55:30 \ No newline at end of file diff --git a/Web/Server/Server.py b/Web/Server/Server.py deleted file mode 100644 index 6070406..0000000 --- a/Web/Server/Server.py +++ /dev/null @@ -1,83 +0,0 @@ -import os -try: #python3 - from urllib.request import urlopen -except: #python2 - from urllib2 import urlopen -from flask import Flask, flash, request, redirect, render_template, Response -from werkzeug.utils import secure_filename -import requests -import json - -app = Flask(__name__) -app.secret_key = "ski u mah" -app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 - -ALLOWED_EXTENSIONS = set(['py']) - -PI_URL = 'http://localhost:8000' - -# UNCOMMENT IF RUNNING PI.PY ON PI -#PI_URL = 'http://192.168.1.10:8000' - -RESULTS_DESTINATION = "Results/results.csv" - -def allowed_file(filename): - return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS - -@app.route('/') -def home(): - return render_template('index.html') - -@app.route('/upload', methods=['POST']) -def upload_file(): - if request.method == 'POST': - # Check if the post request has the file part - if 'file' not in request.files: - print("hi") - return render_template('index.html', error = 'No file part') - - # Grab the file - file = request.files['file'] - if file.filename == '': - print("hi") - return render_template('index.html', error = 'No file selected for uploading') - - # Send the file content as a post to the PI - if file and allowed_file(file.filename): - - dictToSend = {'filename':file.filename, 'file_content':file.read()} - file.close() - print('Running test') - response = requests.post(PI_URL + '/tests/endpoint', json=dictToSend) - - results_filename = json.loads(response.text)[u'results_filename'] - results_content = json.loads(response.text)[u'results_content'] - flash('Results file:' + results_filename) - flash('Response from server:' + results_content) - - results = open(RESULTS_DESTINATION, "w") - results.write(results_content) - results.close() - - return render_template('results.html') - else: - print("hi") - return render_template('index.html', error = 'Allowed file types are .py') - return render_template('index.html', error = 'No file selected') - -@app.route('/results', methods=['GET']) -def download(): - # Grab content from results file - with open(RESULTS_DESTINATION, 'r') as results: - results_content = results.read() - results.close() - - # Put content as a download file - return Response( - results_content, - mimetype="text/csv", - headers={"Content-disposition": - "attachment; filename=results.csv"}) - -if __name__ == "__main__": - app.run(host="localhost", port=5000) \ No newline at end of file diff --git a/Web/Server/static/Server.css b/Web/Server/static/Server.css deleted file mode 100644 index 10d8b23..0000000 --- a/Web/Server/static/Server.css +++ /dev/null @@ -1,64 +0,0 @@ -.container{ - color: white; - background-color: maroon; - border-style: solid; - border: 1px solid #d5d6d2; - text-align: center; - margin:5px; -} - -.button { - background-color: gold; - border: solid; - border-color:#d5d6d2; - color: black; - padding: 15px 32px; - text-align: center; - text-decoration: none; - display: inline-block; - font-size: 16px; -} - -.button:hover{ - background-color: white; - cursor: pointer; -} - -a{ - color:white; - text-decoration:none; -} -a:hover{ - text-decoration:underline -} - -#main{ - color: black; - background-color: #d5d6d2; - border-style: solid; - border: 1px solid #d5d6d2; - text-align: center; - margin:5px; -} - -#about{ - display: none; -} - -#title{ - font-size: xx-large; -} - -#subtitle{ - font-size: large; -} - -#choose_file{ - border: none; - text-decoration: none; - display: inline-block; -} - -#submit{ - -} \ No newline at end of file diff --git a/Web/Server/static/Server.js b/Web/Server/static/Server.js deleted file mode 100644 index 6c2be18..0000000 --- a/Web/Server/static/Server.js +++ /dev/null @@ -1,19 +0,0 @@ -function showLoad(){ - var paragraph = document.getElementById("running"); - var text = document.createTextNode("Running Test, Please wait for Results"); - paragraph.appendChild(text); - - var div = document.getElementById("upload"); - if (div.style.display !== 'none') { - div.style.display = 'none'; - } -} - -function toggleAbout(){ - var x = document.getElementById("about"); - if (x.style.display === "none") { - x.style.display = "block"; - } else { - x.style.display = "none"; - } -} \ No newline at end of file diff --git a/Web/Server/templates/base.html b/Web/Server/templates/base.html deleted file mode 100644 index a1bc09b..0000000 --- a/Web/Server/templates/base.html +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - ANDI'S PIE - - -
- {% block content %} - default content - {% endblock %} -
- - \ No newline at end of file diff --git a/Web/Server/templates/index.html b/Web/Server/templates/index.html deleted file mode 100644 index 6f7e738..0000000 --- a/Web/Server/templates/index.html +++ /dev/null @@ -1,26 +0,0 @@ -{% extends "base.html" %} - -{% block content %} -
-

Upload a python file onto the inverted pendulum

-

- {% if error %} -

{{ error }}

- {% endif %} -

- -
-
-

- -

-
-

- -

-
-
- -
- -{% endblock %} diff --git a/Web/Server/templates/results.html b/Web/Server/templates/results.html deleted file mode 100644 index dd32d87..0000000 --- a/Web/Server/templates/results.html +++ /dev/null @@ -1,13 +0,0 @@ -{% extends "base.html" %} - -{% block content %} -
-
-
- -
- -
- -
-{% endblock %} \ No newline at end of file -- cgit v1.2.3