aboutsummaryrefslogtreecommitdiffstats
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
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 '')
-rw-r--r--.gitmodules6
m---------Uploads/ee4951W_pendulum_web0
m---------Web0
-rw-r--r--Web/PI/PI.py48
-rw-r--r--Web/PI/Results/PLACEHOLDER.txt0
-rw-r--r--Web/PI/Uploads/PLACEHOLDER0
-rw-r--r--Web/PI/test2.py7
-rw-r--r--Web/Server/Results/PLACEHOLDER0
-rw-r--r--Web/Server/Results/results.csv2
-rw-r--r--Web/Server/Server.py83
-rw-r--r--Web/Server/static/Server.css64
-rw-r--r--Web/Server/static/Server.js19
-rw-r--r--Web/Server/templates/base.html48
-rw-r--r--Web/Server/templates/index.html26
-rw-r--r--Web/Server/templates/results.html13
-rw-r--r--Web/requirements.txt18
-rw-r--r--Web/test.py17
17 files changed, 3 insertions, 348 deletions
diff --git a/.gitmodules b/.gitmodules
index 7acc11c..dd3be4d 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,3 @@
-[submodule "Uploads/ee4951W_pendulum_web"]
- path = Uploads/ee4951W_pendulum_web
- url = https://github.com/RosstheRoss/ee4951W_pendulum_web.git
+[submodule "4951w-pendulum"]
+ path = Web
+ url = git@github.com:RosstheRoss/4951w-pendulum.git
diff --git a/Uploads/ee4951W_pendulum_web b/Uploads/ee4951W_pendulum_web
deleted file mode 160000
-Subproject e5abe2e724bf73bb7bd07539297e03c19ca0c38
diff --git a/Web b/Web
new file mode 160000
+Subproject fb66bbca33e6d7c1eacc38599c3eb7d35d9e0b1
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)
diff --git a/Web/PI/Results/PLACEHOLDER.txt b/Web/PI/Results/PLACEHOLDER.txt
deleted file mode 100644
index e69de29..0000000
--- a/Web/PI/Results/PLACEHOLDER.txt
+++ /dev/null
diff --git a/Web/PI/Uploads/PLACEHOLDER b/Web/PI/Uploads/PLACEHOLDER
deleted file mode 100644
index e69de29..0000000
--- a/Web/PI/Uploads/PLACEHOLDER
+++ /dev/null
diff --git a/Web/PI/test2.py b/Web/PI/test2.py
deleted file mode 100644
index a5eb806..0000000
--- a/Web/PI/test2.py
+++ /dev/null
@@ -1,7 +0,0 @@
-import subprocess
-import os
-
-subprocess.call(["python", "Uploads/upload.py"])
-print("end of script")
-
-os.remove("Uploads/upload.py") \ No newline at end of file
diff --git a/Web/Server/Results/PLACEHOLDER b/Web/Server/Results/PLACEHOLDER
deleted file mode 100644
index e69de29..0000000
--- a/Web/Server/Results/PLACEHOLDER
+++ /dev/null
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 @@
-<html>
- <head>
- <link rel="stylesheet" href="/static/Server.css">
- <script type="text/javascript" src="/static/Server.js"></script>
- </head>
- <body>
- <title>ANDI'S PIE</title>
- <nav class = "container">
- <h1 id="title">Remotely Accessible Inverted Pendulum</h1>
-
- <button class="button" onclick="toggleAbout()">About</button>
-
- <div id="about">
- <h2 id="subtitle">
- By Alin Butoi, Paul D’Amico, Dat Nguyen, Ross Olson, Rachel Schow <br>
- Advisor: Professor Andrew Lamperski <br>
- Sponsored by the University of Minnesota - Twin Cities <br>
- </h2>
- <h1>Team ANDI'S PIE</h1>
- <div>
- Andy’s Nifty Dynamic Inverted Swinging Pendulum in Equilibrium
- </div>
-
- <h1>Background</h1>
- <p>
- Our team developed an inverted pendulum system that could be accessed over a computer network for use by students. The inverted pendulum is a common controls problem used in academia. This problem teaches students concepts of control loops, data filtering, and machine learning.
- </p>
-
- <h1> What is an Inverted Pendulum? </h1>
- <p>
- A vertical pendulum that is balanced via the base moving. <br>
- Controlled movements are determined by measuring the position and speed of the pendulum and base.
- </p>
-
- <a href="https://github.umn.edu/damic014/ee4950-inverted-pendulum"> Link to Github</a>
- </div>
-
- <br>
- <br>
- </nav>
-
- <div id="main">
- {% block content %}
- default content
- {% endblock %}
- </div>
- </body>
-</html> \ 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 %}
- <div id="upload">
- <h2>Upload a python file onto the inverted pendulum</h2>
- <p>
- {% if error %}
- <h2>{{ error }}</h2>
- {% endif %}
- </p>
-
- <form method="post" action="/upload" enctype="multipart/form-data">
- <dl>
- <p>
- <input id="choose_file" type="file" name="file" autocomplete="off" required>
- </p>
- </dl>
- <p>
- <input id="submit" type="submit" value="Submit"> <!-- onclick="showLoad()"> -->
- </p>
- </form>
- </div>
-
- <div id="running"></div>
-
-{% 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 %}
- <br>
- <br>
- <form method="get" action="/results">
- <button type="submit">Download Results File</button>
- </form>
-
- <form method="get" action="/">
- <button type="submit">Upload another file</button>
- </form>
-{% endblock %} \ No newline at end of file
diff --git a/Web/requirements.txt b/Web/requirements.txt
deleted file mode 100644
index f0cc7a5..0000000
--- a/Web/requirements.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-certifi==2019.9.11
-chardet==3.0.4
-Click==7.0
-Flask==1.1.1
-Flask-Bootstrap==3.2.0.2
-Flask-WTF==0.14.2
-gunicorn==19.9.0
-idna==2.8
-itsdangerous==1.1.0
-Jinja2==2.10.3
-MarkupSafe==1.1.1
-Pillow==2.5.1
-requests==2.22.0
-simplejson==3.6.0
-urllib3==1.25.6
-virtualenv==16.7.7
-Werkzeug==0.16.0
-WTForms==2.2.1
diff --git a/Web/test.py b/Web/test.py
deleted file mode 100644
index 8c15f58..0000000
--- a/Web/test.py
+++ /dev/null
@@ -1,17 +0,0 @@
-import time, os, sys
-from datetime import datetime
-
-file_name = os.path.basename(sys.argv[0])
-
-file_name = file_name.split(".")[0]
-
-now = datetime.now()
-current_time = now.strftime("%H:%M:%S")
-print("Current Time = " + current_time)
-
-f = open("Results/" + file_name + "_results.csv", "w+")
-f.write("THIS IS RESULTS TEXT\n")
-f.write("Current Time = " + current_time)
-f.close()
-print("Running test.py for ~ 5 seconds.")
-time.sleep(5)