Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
IoTSmartMeter
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kristian.tan
IoTSmartMeter
Commits
b9e3aa7b
Commit
b9e3aa7b
authored
Nov 13, 2019
by
Kristian Tan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rerouting
parent
396fc6a0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
10 deletions
+18
-10
app.py
app.py
+4
-1
main.html
templates/main.html
+14
-9
No files found.
app.py
View file @
b9e3aa7b
...
...
@@ -136,7 +136,7 @@ def create_entry(change_pin):
pins
[
change_pin
][
'on_date'
]
=
None
@
app
.
route
(
'/handle_data'
,
methods
=
[
'POST'
])
@
app
.
route
(
'/handle_data
/update_kWh
'
,
methods
=
[
'POST'
])
def
handle_data
():
new_price
=
request
.
form
[
'kWhprice'
]
os
.
environ
[
'cost_per_kWh'
]
=
str
(
new_price
)
...
...
@@ -147,6 +147,9 @@ def handle_data():
}
return
render_template
(
'main.html'
,
**
template_data
)
@
app
.
route
(
"/devices/add_device"
)
def
add_new_device
():
pass
if
__name__
==
'__main__'
:
app
.
run
(
host
=
'0.0.0.0'
,
port
=
8090
)
templates/main.html
View file @
b9e3aa7b
...
...
@@ -13,15 +13,20 @@
<div
class=
"device_list"
>
<h3
class=
"device_list_title"
>
Device Listing and Status
</h3>
{% for pin in pins %}
<p>
{{ pins[pin].name }} :
{% if pins[pin].state == true %}
{% for pin in pins %}
<p>
{{ pins[pin].name }} :
{% if pins[pin].state == true %}
(
<a
href=
"/toggle/{{pin}}"
>
turn off
</a>
)
{% else %}
(
<a
href=
"/toggle/{{pin}}"
>
turn on
</a>
)
{% endif %}
</p>
{% endfor %}
{% else %}
(
<a
href=
"/toggle/{{pin}}"
>
turn on
</a>
)
{% endif %}
</p>
<p><a
href=
"/devices/add_device"
>
Add device
</a></p>
{% endfor %}
<p></p>
</div>
<div
class=
"smart_meter"
>
...
...
@@ -42,7 +47,7 @@
</div>
</div>
<div
class=
"inputs"
>
<form
action=
"{{ url_for('handle_data') }}"
method=
"post"
>
<form
action=
"{{ url_for('handle_data
/update_kWh
') }}"
method=
"post"
>
Change cost per kWh:
<input
type=
"text"
name=
"kWhprice"
>
<input
type=
"submit"
>
</form>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment