diff --git a/README.md b/README.md index 55c6243..f36fbbf 100644 --- a/README.md +++ b/README.md @@ -54,10 +54,18 @@ TODO https://github.com/adafruit/Adafruit_Python_DHT TODO +### Webserver set up + +I used apache, so if you want to use a different webserver, such as nginx, sorry, but your on your own. + +There are two options available: the 'simple' way, which is much slower, or wsgi, which runs very fast. + +TODO + ### Configure Open ```./framework/settings.py``` and fill out the required settings, such as your API key & ZIP code. Make any other changes you wish to make. -Open ```./framework/sensors.py``` and make any changes needed to support your specific sensors. This should be easy if using similar sensors t one sI used, or it may require more work, depending on the specific sensors you have. +Open ```./framework/sensors.py``` and make any changes needed to support your specific sensors. This should be easy if using similar sensors t one sI used, or it may require more work, depending on the specific sensors you have. \ No newline at end of file diff --git a/framework/http_reset_rain.py b/framework/http_reset_rain.py new file mode 100644 index 0000000..f9ca3fc --- /dev/null +++ b/framework/http_reset_rain.py @@ -0,0 +1,24 @@ +#!python +# -*- coding: UTF-8 -*- +from database import * + +# +# This file will reset the current rainfall to 0. +def reset_rain(): + # Reset rain_since_reset in the table + # (╯°□°)╯︵ ┻━┻ + now = Table_Now.get(1) + now.sync() + now.Out_Rain_Since_Reset = 0 + +# If file ran directly, reset the rain as well. +# We use this to be able to support wsgi OR straight python. +if __name__ == '__main__': + # Print the Header + print "Content-Type: text/html;charset=utf-8" + print + + reset_rain() + + # Print the Data + print "reset!" \ No newline at end of file diff --git a/framework/status.py b/framework/http_status.py similarity index 90% rename from framework/status.py rename to framework/http_status.py index 85086f9..c39a817 100644 --- a/framework/status.py +++ b/framework/http_status.py @@ -31,7 +31,8 @@ def get_json(): #Now return the json as a string return json.dumps(data) -# If file ran directly, print the json directly as well +# If file ran directly, print the json directly as well. +# We use this to be able to support wsgi OR straight python. if __name__ == '__main__': # Print the Header print "Content-Type: application/json;charset=utf-8" diff --git a/framework/status.wsgi b/framework/http_status.wsgi similarity index 95% rename from framework/status.wsgi rename to framework/http_status.wsgi index a2b4eff..50666d7 100644 --- a/framework/status.wsgi +++ b/framework/http_status.wsgi @@ -1,5 +1,5 @@ #!python -from status import * +from http_status import * # # This is requested by the index page every time it needs to update the data. diff --git a/framework/reset_rain.py b/framework/reset_rain.py deleted file mode 100644 index de5e97f..0000000 --- a/framework/reset_rain.py +++ /dev/null @@ -1,24 +0,0 @@ -#!python -# -*- coding: UTF-8 -*- -from database import * -import time - -# -# This file will reset the current rainfall to 0. -# We have it look executing 3 times, once per second, because there's -# A strange race condition that can cause it to not actually be reset. -# - -# Print the Header -print "Content-Type: text/html;charset=utf-8" -print - -# Reset rain_since_reset in the table -# (╯°□°)╯︵ ┻━┻ -for x in range(0, 3): - now = Table_Now.get(1) - now.Out_Rain_Since_Reset = 0 - time.sleep(1) - -# Print the Data -print "reset!" \ No newline at end of file diff --git a/js/value_refresher.js b/js/value_refresher.js index 2d869c8..58bc0be 100644 --- a/js/value_refresher.js +++ b/js/value_refresher.js @@ -62,7 +62,7 @@ function update(data) { // Handles when the user clicks the button to reset the rainfall. function reset_rain() { $.ajax({ - url: "/framework/reset_rain.py", + url: "/framework/http_reset_rain.py", }); }