Skip to content

Instantly share code, notes, and snippets.

@hibellm
Forked from ivanleoncz/flask_job_scheduler.py
Created June 22, 2019 07:49
Show Gist options
  • Save hibellm/a14cf3532dea6860702dbe1be805e3e2 to your computer and use it in GitHub Desktop.
Save hibellm/a14cf3532dea6860702dbe1be805e3e2 to your computer and use it in GitHub Desktop.
Demonstrating APScheduler feature for small Flask App.
#!/usr/bin/python3
""" Demonstrating APScheduler feature for small Flask App. """
from apscheduler.schedulers.background import BackgroundScheduler
from flask import Flask
def sensor():
""" Function for test purposes. """
print("Scheduler is alive!")
sched = BackgroundScheduler(daemon=True)
sched.add_job(sensor,'interval',seconds=60)
sched.start()
app = Flask(__name__)
@app.route("/home")
def home():
""" Function for test purposes. """
return "Welcome Home :) !"
if __name__ == "__main__":
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment