Skip to content

Html debug #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ services:
context: .
dockerfile: ./Dockerfile.dev
ports:
- '7000:7000'
- '10000:7000'
volumes:
- ./static:/app/templates
30 changes: 21 additions & 9 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,28 @@
import subprocess
import threading
import time

from subprocess import Popen, PIPE, STDOUT

from sign_message import SignMessage

proc = None
sign_message = None

def turnOff():
global proc
global sign_message
success = False
if args.development:
success = True
sign_message = None
if proc != None:
proc.kill()
sign_message = None
success = True



app = Flask(__name__)
parser = argparse.ArgumentParser()
parser.add_argument(
Expand Down Expand Up @@ -92,18 +108,13 @@ def random_message():

@app.route("/api/turn-off", methods=["GET"])
def turn_off():
global proc
global sign_message
success = False
if proc != None:
proc.kill()
sign_message = None
success = True
turnOff()
return jsonify({
"success": success
})



@app.route("/api/update-sign", methods=["POST"])
def update_sign():
global proc
Expand All @@ -129,8 +140,9 @@ def update_sign():
sign_message = None
return "Could not update sign", 500
@app.route('/')
def home():
return render_template('index.html')
def home():
return render_template('index.html')


if __name__ == "__main__":
# give the last opened an initial value of now,
Expand Down
41 changes: 40 additions & 1 deletion static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,45 @@
<title>SCE LED Sign</title>
</head>
<body>
<h3>hello from the sign :D</h3>
<h3 id = "isOff" style= "display: none">Sign is Off</h3>
<marquee id = "test" direction ="left" style = "width: 150px; border-style: solid; border-width: 5px; font-family: monospace;font-size: 20px;"/>

<script>
const handleFetch = async () =>{
url = new URL('api/health-check', window.location.origin)
try{
const res = await fetch(url.href);
if(!res.ok){
throw new Error("Could not fetch resource");
}

const data = await res.json();

console.log(Object.hasOwn(data, 'text'));

if (Object.hasOwn(data, 'text')) {
document.getElementById("test").style.color = data.textColor;
document.getElementById("test").style.backgroundColor = data.backgroundColor;
document.getElementById("test").style.borderColor = data.borderColor;
document.getElementById("test").innerHTML = data.text;
document.getElementById("test").setAttribute('scrollamount', data.scrollSpeed);
document.getElementById("test").style.display = 'block';

document.getElementById("isOff").style.display = 'none';
return;
} else {
document.getElementById("isOff").style.display = 'block';
document.getElementById("test").style.display = 'none';
}


}catch(err){
console.log(err)
}
}
handleFetch();

</script>
</body>

</html>