Compare commits
No commits in common. "78dca5c55939208fb82c60365789b9407f8ee73b" and "e7cbbb8226d2d0f74d1f0b4cfa82f767f9c61785" have entirely different histories.
78dca5c559
...
e7cbbb8226
0
build/lib/weblight/__init__.py
Normal file
0
build/lib/weblight/__init__.py
Normal file
31
build/lib/weblight/__main__.py
Normal file
31
build/lib/weblight/__main__.py
Normal file
@ -0,0 +1,31 @@
|
||||
from flask import Flask
|
||||
from flask import render_template
|
||||
from flask import redirect
|
||||
from flask import url_for
|
||||
from flask import make_response
|
||||
|
||||
import RPi.GPIO as GPIO
|
||||
|
||||
RELAY_1 = 26
|
||||
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
GPIO.setup(RELAY_1,GPIO.OUT)
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
return render_template('index.html')
|
||||
|
||||
@app.route('/<state>', methods=['POST'])
|
||||
def reroute(state):
|
||||
if state == 'on':
|
||||
GPIO.output(RELAY_1, 0)
|
||||
else:
|
||||
GPIO.output(RELAY_1, 1)
|
||||
|
||||
response = make_response(redirect(url_for('index')))
|
||||
return response
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=False, host='0.0.0.0', port=8000)
|
52
build/lib/weblight/templates/index.html
Normal file
52
build/lib/weblight/templates/index.html
Normal file
@ -0,0 +1,52 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Yard Light</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style>
|
||||
html, body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 18px !important;
|
||||
font-family: 'Muli', arial, verdana, helvetica, sans-serif;
|
||||
font-weight: 300;
|
||||
font-style: normal;
|
||||
height: 100%;
|
||||
color: #b6b6b6;
|
||||
background: #282929;
|
||||
}
|
||||
|
||||
body {
|
||||
display:flex;
|
||||
flex-direction:column;
|
||||
}
|
||||
|
||||
h1 {text-align: center;}
|
||||
p {text-align: center;}
|
||||
div {text-align: center;}
|
||||
|
||||
.button {
|
||||
color: #b6b6b6;
|
||||
background-color: #3d5f69;
|
||||
padding: 10px;
|
||||
margin: 10px 0;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-size: 1.2rem;
|
||||
width: 12rem;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Yard Light</h1>
|
||||
<p>
|
||||
<form action="/on" method="POST">
|
||||
<div><button class="button">On</button></div><br>
|
||||
</form>
|
||||
<form action="/off" method="POST">
|
||||
<div><button class="button">Off</button></div><br>
|
||||
</form>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
3
build/scripts-3.7/start-weblight
Executable file
3
build/scripts-3.7/start-weblight
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
python -m weblight $@
|
Loading…
Reference in New Issue
Block a user