commit 07e10f991c2910562a0ab7821018c0725baefbd7 Author: Thomas Klaehn Date: Mon Jan 18 09:56:52 2021 +0100 Initial commit Signed-off-by: Thomas Klaehn diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5c80531 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +__pycache__ + +dist/ diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..84dae5c --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +recursive-include weblight/templates * diff --git a/Web_Light.egg-info/PKG-INFO b/Web_Light.egg-info/PKG-INFO new file mode 100644 index 0000000..a5c4412 --- /dev/null +++ b/Web_Light.egg-info/PKG-INFO @@ -0,0 +1,10 @@ +Metadata-Version: 1.0 +Name: Web-Light +Version: 1 +Summary: UNKNOWN +Home-page: UNKNOWN +Author: Thomas Klaehn +Author-email: tkl@blackfinn.de +License: UNKNOWN +Description: UNKNOWN +Platform: UNKNOWN diff --git a/Web_Light.egg-info/SOURCES.txt b/Web_Light.egg-info/SOURCES.txt new file mode 100644 index 0000000..0e9acc8 --- /dev/null +++ b/Web_Light.egg-info/SOURCES.txt @@ -0,0 +1,12 @@ +MANIFEST.in +setup.py +start-weblight +Web_Light.egg-info/PKG-INFO +Web_Light.egg-info/SOURCES.txt +Web_Light.egg-info/dependency_links.txt +Web_Light.egg-info/not-zip-safe +Web_Light.egg-info/requires.txt +Web_Light.egg-info/top_level.txt +weblight/__init__.py +weblight/__main__.py +weblight/templates/index.html \ No newline at end of file diff --git a/Web_Light.egg-info/dependency_links.txt b/Web_Light.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Web_Light.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/Web_Light.egg-info/not-zip-safe b/Web_Light.egg-info/not-zip-safe new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Web_Light.egg-info/not-zip-safe @@ -0,0 +1 @@ + diff --git a/Web_Light.egg-info/requires.txt b/Web_Light.egg-info/requires.txt new file mode 100644 index 0000000..e3e9a71 --- /dev/null +++ b/Web_Light.egg-info/requires.txt @@ -0,0 +1 @@ +Flask diff --git a/Web_Light.egg-info/top_level.txt b/Web_Light.egg-info/top_level.txt new file mode 100644 index 0000000..525cd6e --- /dev/null +++ b/Web_Light.egg-info/top_level.txt @@ -0,0 +1 @@ +weblight diff --git a/build/lib/weblight/__init__.py b/build/lib/weblight/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/build/lib/weblight/__main__.py b/build/lib/weblight/__main__.py new file mode 100644 index 0000000..2dc4dde --- /dev/null +++ b/build/lib/weblight/__main__.py @@ -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('/', 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) diff --git a/build/lib/weblight/templates/index.html b/build/lib/weblight/templates/index.html new file mode 100644 index 0000000..7cfdc6e --- /dev/null +++ b/build/lib/weblight/templates/index.html @@ -0,0 +1,52 @@ + + + + Yard Light + + + + + +

Yard Light

+

+

+

+
+
+

+
+

+ + diff --git a/build/scripts-3.7/start-weblight b/build/scripts-3.7/start-weblight new file mode 100755 index 0000000..d4874f3 --- /dev/null +++ b/build/scripts-3.7/start-weblight @@ -0,0 +1,3 @@ +#!/bin/bash + +python -m weblight $@ diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..0499cfd --- /dev/null +++ b/setup.py @@ -0,0 +1,24 @@ +import sys +import os +import shutil +import stat +from setuptools import setup + +NAME = 'Web Light' +VERSION = '1' +AUTHOR = 'Thomas Klaehn' +EMAIL = 'tkl@blackfinn.de' +PACKAGES = ['weblight'] +SCRIPTS = ['start-weblight'] +SERVICEDIR = "/lib/systemd/system" +REQUIRES = ['Flask'] +DAEMON_START_SCRIPT = os.path.join(SERVICEDIR, 'weblight.service') + +if sys.argv[1] == 'install': + os.makedirs(SERVICEDIR, exist_ok=True) + shutil.copyfile('weblight.service', DAEMON_START_SCRIPT) + os.chmod(DAEMON_START_SCRIPT, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH) + +setup(name=NAME, version=VERSION, long_description=__doc__, author=AUTHOR, author_email=EMAIL, + packages=PACKAGES, scripts=SCRIPTS, include_package_data=True, zip_safe=False, + install_requires=REQUIRES) diff --git a/start-weblight b/start-weblight new file mode 100644 index 0000000..d4874f3 --- /dev/null +++ b/start-weblight @@ -0,0 +1,3 @@ +#!/bin/bash + +python -m weblight $@ diff --git a/weblight.service b/weblight.service new file mode 100644 index 0000000..746c947 --- /dev/null +++ b/weblight.service @@ -0,0 +1,10 @@ +[Unit] +Description=Weblight +After=multi-user.target + +[Service] +Type=idle +ExecStart=/usr/local/bin/start-weblight + +[Install] +WantedBy=multi-user.target diff --git a/weblight/__init__.py b/weblight/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/weblight/__main__.py b/weblight/__main__.py new file mode 100644 index 0000000..2dc4dde --- /dev/null +++ b/weblight/__main__.py @@ -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('/', 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) diff --git a/weblight/templates/index.html b/weblight/templates/index.html new file mode 100644 index 0000000..7cfdc6e --- /dev/null +++ b/weblight/templates/index.html @@ -0,0 +1,52 @@ + + + + Yard Light + + + + + +

Yard Light

+

+

+

+
+
+

+
+

+ +