diff --git a/default.nix b/default.nix index aa9dbd4..a38b7c5 100644 --- a/default.nix +++ b/default.nix @@ -1,7 +1,8 @@ { python }: with python.pkgs; -buildPythonPackage rec { +buildPythonApplication rec { name = "mqtt-dash"; src = ./.; propagatedBuildInputs = [ flask ]; + doCheck = false; } diff --git a/mqtt-dash b/mqtt-dash new file mode 100755 index 0000000..a2bf26b --- /dev/null +++ b/mqtt-dash @@ -0,0 +1,9 @@ +#!/usr/bin/env python + +import os + +from mqtt_dash.app import app + + +app.secret_key = os.urandom(12) +app.run(debug=False, host='0.0.0.0', port=4000) diff --git a/mqtt_dash/__init__.py b/mqtt_dash/__init__.py new file mode 100644 index 0000000..c07c459 --- /dev/null +++ b/mqtt_dash/__init__.py @@ -0,0 +1 @@ +from .app import app diff --git a/app.py b/mqtt_dash/app.py similarity index 98% rename from app.py rename to mqtt_dash/app.py index 134c0dd..faa302d 100755 --- a/app.py +++ b/mqtt_dash/app.py @@ -2,7 +2,6 @@ from flask import Flask, flash, redirect, render_template_string from flask import render_template, request, session, abort -import os import uuid app = Flask(__name__) @@ -200,8 +199,3 @@ def home(): row_layout("Some buttons", button_widget("test", "set to 1", 1), button_widget("test", "set to foo", 'foo')) ]) - - -if __name__ == "__main__": - app.secret_key = os.urandom(12) - app.run(debug=True, host='0.0.0.0', port=4000) diff --git a/templates/base.html b/mqtt_dash/templates/base.html similarity index 100% rename from templates/base.html rename to mqtt_dash/templates/base.html diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..59bac34 --- /dev/null +++ b/setup.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python + +from distutils.core import setup + +setup( + name='mqtt-dash', + version='0.1', + description='MQTT Dashboard', + author='0xee', + author_email='mqtt-dash@0xee.eu', + packages=['mqtt_dash'], + scripts=['mqtt-dash'], + package_data={'mqtt_dash': ['templates/*.html']}, +) diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..1c20729 --- /dev/null +++ b/shell.nix @@ -0,0 +1,2 @@ +{ pkgs ? import {} }: +pkgs.callPackage ./. { python = pkgs.python3; }