changeset 4:e7c8dcc5fc15

Make the weather server pip-installable and locally runnable.
author Paul Fisher <paul@pfish.zone>
date Sun, 29 Sep 2019 15:10:18 -0400
parents b42c4bfe57c7
children 368f732f13d0
files requirements.txt setup.py weather_server/server.py
diffstat 3 files changed, 33 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/requirements.txt	Sun Sep 29 15:10:18 2019 -0400
@@ -0,0 +1,5 @@
+attrs
+flask
+flup
+pymongo
+pytz
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/setup.py	Sun Sep 29 15:10:18 2019 -0400
@@ -0,0 +1,16 @@
+import setuptools
+
+setuptools.setup(
+    name='weather-server',
+    version='0.0.1',
+    packages=setuptools.find_packages(),
+    python_requires='>=3.7',
+    install_requires=[
+        'attrs',
+        'flask',
+        'flup',
+        'pymongo',
+        'pytz',
+    ],
+    setup_requires=['wheel'],
+)
--- a/weather_server/server.py	Sun Sep 29 11:52:48 2019 -0400
+++ b/weather_server/server.py	Sun Sep 29 15:10:18 2019 -0400
@@ -1,6 +1,7 @@
+import hmac
+
 import bson
 import flask
-import hmac
 
 from . import common
 from . import locations
@@ -65,3 +66,13 @@
             date=date)
 
     return app
+
+
+def main(argv):
+    """Main function for a simple local demo."""
+    app = server.build_app(argv[0])
+    app.run(host='0.0.0.0')
+
+
+if __name__ == '__main__':
+    main(sys.argv[1:])