Skip to content

Commit

Permalink
Fix run without WSGI server
Browse files Browse the repository at this point in the history
  • Loading branch information
anxuae committed Sep 26, 2018
1 parent 7f52595 commit c6fc07f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pih2o/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

"""An automatic plant watering application in pure Python for the Raspberry Pi."""

__version__ = "1.0.1"
__version__ = "1.0.2"

from pih2o.h2o import create_app # For WSGI loading
10 changes: 8 additions & 2 deletions pih2o/h2o.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def shutdown_daemon(self):


def create_app(cfgfile="~/.config/pih2o/pih2o.cfg"):
"""Application factory.
"""Entry point to use with a WSGI server (e.g. gunicorn).
"""
parser = argparse.ArgumentParser(usage="%(prog)s [options]", description=pih2o.__doc__)

Expand Down Expand Up @@ -283,6 +283,12 @@ def create_app(cfgfile="~/.config/pih2o/pih2o.cfg"):
sys.exit(0)


if __name__ == '__main__':
def main():
"""Entry point in case of 'direct' run (without WSGI server)
"""
app = create_app()
app.run(use_reloader=False) # Dont want to start the daemon 2 times


if __name__ == '__main__':
main()

0 comments on commit c6fc07f

Please sign in to comment.