Skip to content

Commit

Permalink
http request standardization
Browse files Browse the repository at this point in the history
  • Loading branch information
1n5aN1aC committed Dec 14, 2015
1 parent fcc3e44 commit 7505bf5
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 28 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
24 changes: 24 additions & 0 deletions framework/http_reset_rain.py
Original file line number Diff line number Diff line change
@@ -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!"
3 changes: 2 additions & 1 deletion framework/status.py → framework/http_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion framework/status.wsgi → framework/http_status.wsgi
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
24 changes: 0 additions & 24 deletions framework/reset_rain.py

This file was deleted.

2 changes: 1 addition & 1 deletion js/value_refresher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
});
}

Expand Down

0 comments on commit 7505bf5

Please sign in to comment.