Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mason-today-web
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
8
Issues
8
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SRCT
mason-today-web
Commits
f5408b5b
Commit
f5408b5b
authored
Jul 12, 2018
by
Landon DeCoito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added scheduling to the __init__
parent
90f146a4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
5 deletions
+17
-5
mason-today/__init__.py
mason-today/__init__.py
+17
-5
No files found.
mason-today/__init__.py
View file @
f5408b5b
...
...
@@ -6,13 +6,16 @@ from flask import render_template
# app imports
from
parscript
import
load_data
from
getconnectedscript
import
load_getconn_data
from
redisactions
import
*
from
appmethods
import
*
# python imports
import
json
# other imports
import
redis
from
redisactions
import
*
import
schedule
import
time
# setting up flask instance
app
=
Flask
(
__name__
)
...
...
@@ -20,6 +23,11 @@ app = Flask(__name__)
# setting up redis database
redisdb
=
redis
.
from_url
(
"redis://localhost:6379/0"
,
db
=
0
)
# setting up cacheing
schedule
.
every
().
day
.
at
(
"02:00"
).
do
(
updatebothdbs
)
# schedule.every(5).seconds.do(updatebothdbs)
@
app
.
route
(
"/"
)
def
display_default
():
resp
=
render_template
(
'welcomepage.html'
)
...
...
@@ -28,15 +36,19 @@ def display_default():
@
app
.
route
(
"/api/25live"
)
def
display_data
():
livedbfill
(
json
.
dumps
(
load_data
(),
ensure_ascii
=
False
))
resp
=
Response
(
redisdb
.
get
(
"livedict"
))
# .encode('utf-8'))
resp
=
Response
(
redisdb
.
get
(
"livedict"
))
# .encode('utf-8'))
resp
.
headers
[
'Content-Type'
]
=
'application/json; charset=utf-8'
return
resp
@
app
.
route
(
"/api/getconnected"
)
def
display_GC_data
():
gcdbfill
(
json
.
dumps
(
load_getconn_data
(),
ensure_ascii
=
False
))
resp
=
Response
(
redisdb
.
get
(
"gcdict"
))
# .encode('utf-8'))
resp
=
Response
(
redisdb
.
get
(
"gcdict"
))
# .encode('utf-8'))
resp
.
headers
[
'Content-Type'
]
=
'application/json; charset=utf-8'
return
resp
# this needs to be uncommented in order for the scheduler to work
# but it's being weird cause it's hogging the thread
# while True:
# schedule.run_pending()
# time.sleep(5)
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