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
1521640a
Commit
1521640a
authored
Nov 13, 2019
by
Kristian Tan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
query by not all
parent
9d956baa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
app.py
app.py
+9
-5
No files found.
app.py
View file @
1521640a
...
@@ -33,6 +33,7 @@ class DailyUsage(db.Model):
...
@@ -33,6 +33,7 @@ class DailyUsage(db.Model):
db
.
create_all
()
db
.
create_all
()
DailyUsage
.
query
()
.
delete
()
# Create dictionary to store pin info
# Create dictionary to store pin info
pins
=
{
pins
=
{
...
@@ -61,7 +62,7 @@ def main():
...
@@ -61,7 +62,7 @@ def main():
@
app
.
route
(
"/<change_pin>"
)
@
app
.
route
(
"/<change_pin>"
)
def
toggle_pin
(
change_pin
):
def
toggle_pin
(
change_pin
):
# TODO: change_pin is somet
h
imes favicon.co for some reason? Fix
# TODO: change_pin is sometimes favicon.co for some reason? Fix
if
change_pin
==
'favicon.ico'
:
if
change_pin
==
'favicon.ico'
:
pass
pass
...
@@ -76,16 +77,19 @@ def toggle_pin(change_pin):
...
@@ -76,16 +77,19 @@ def toggle_pin(change_pin):
message
+=
" off."
message
+=
" off."
if
pins
[
change_pin
][
'on_time'
]
is
not
None
:
if
pins
[
change_pin
][
'on_time'
]
is
not
None
:
uptime
=
str
(
datetime
.
now
()
-
pins
[
change_pin
][
'on_time'
])
uptime
=
str
(
datetime
.
now
()
-
pins
[
change_pin
][
'on_time'
])
d
=
DailyUsage
(
date
=
pins
[
change_pin
][
'on_time'
],
hours
=
uptime
)
print
(
"==========="
)
print
(
"==========="
)
print
(
"
UPTIME STRING: "
+
uptime
)
print
(
"
DAILYUSAGE: "
+
d
)
print
(
"==========="
)
print
(
"==========="
)
d
=
DailyUsage
(
date
=
pins
[
change_pin
][
'on_time'
],
hours
=
uptime
)
db
.
session
.
add
(
d
)
db
.
session
.
add
(
d
)
db
.
session
.
commit
()
db
.
session
.
commit
()
pins
[
change_pin
][
'on_time'
]
=
None
pins
[
change_pin
][
'on_time'
]
=
None
print
(
"=========="
)
print
(
"=========="
)
d
=
DailyUsage
.
query
.
filter_by
(
id
=
1
)
e
=
DailyUsage
.
query
.
filter_by
(
id
=
1
)
print
(
d
)
print
(
"DB ENTRY: "
+
e
)
print
(
"=========="
)
print
(
"=========="
)
else
:
else
:
message
+=
" on."
message
+=
" on."
...
...
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