32 lines
566 B
Python
Executable File
32 lines
566 B
Python
Executable File
#!/usr/bin/python3
|
|
import fetcher
|
|
import time
|
|
from queue import Queue
|
|
from flask import Flask
|
|
|
|
|
|
# Create a queue to get some info how the fetcher is doing
|
|
q = Queue()
|
|
# Start the data collecting
|
|
fetcher.start(q)
|
|
|
|
# Initialize the Flask app
|
|
app = Flask(__name__)
|
|
|
|
@app.route("/")
|
|
def root():
|
|
if not q.empty():
|
|
data = q.get()
|
|
return(str(data))
|
|
else:
|
|
return("Fetcher message queue is empty")
|
|
|
|
@app.route("/fetcher_health")
|
|
def fetcher_health():
|
|
health = fetcher.get_health()
|
|
return(str(health))
|
|
|
|
# Run the app
|
|
if __name__ == "__main__":
|
|
app.run()
|