diff --git a/web/index.html b/web/index.html index 3d24652..c7f295f 100644 --- a/web/index.html +++ b/web/index.html @@ -15,6 +15,11 @@ flex-direction: column; } + label { + font-weight: bold; + font-family: sans, sans-serif; + } + #output { flex: 99 1 auto; } @@ -47,11 +52,13 @@
diff --git a/web/reward_fcgi.py b/web/mhapi_fcgi.py similarity index 57% rename from web/reward_fcgi.py rename to web/mhapi_fcgi.py index 5ad9d4e..40b9b42 100755 --- a/web/reward_fcgi.py +++ b/web/mhapi_fcgi.py @@ -2,7 +2,7 @@ from flup.server.fcgi import WSGIServer -import reward_webapp +from mhapi_wsgi import application if __name__ == '__main__': - WSGIServer(reward_webapp.application).run() + WSGIServer(application).run() diff --git a/web/reward_webapp.py b/web/mhapi_wsgi.py similarity index 85% rename from web/reward_webapp.py rename to web/mhapi_wsgi.py index ec687d0..6f22cfa 100755 --- a/web/reward_webapp.py +++ b/web/mhapi_wsgi.py @@ -12,6 +12,9 @@ import mhrewards DB_VERSION = "20150313" PREFIX = "/mhapi/" +# good for testing, use 1 hour = 3600 for deployment +MAX_AGE = "60" + logging.basicConfig(filename="/tmp/reward_webapp.log", level=logging.INFO) @@ -62,12 +65,12 @@ class App(object): def find_item_rewards(self, req, resp): version = "1" - resp.cache_control = "max-age=60" - resp.etag = DB_VERSION + version + etag = DB_VERSION + version + resp.cache_control = "public, max-age=" + MAX_AGE + resp.etag = etag - self.log.info("etag = %s", resp.etag) - if req.if_match == resp.etag: - return HTTPNotModified() + if etag in req.if_none_match: + return exc.HTTPNotModified() resp.content_type = "text/plan" @@ -83,12 +86,12 @@ class App(object): def get_all_names(self, req, resp): version = "2" - resp.cache_control = "max-age=60" - resp.etag = DB_VERSION + version + etag = DB_VERSION + version + resp.cache_control = "public, max-age=" + MAX_AGE + resp.etag = etag - self.log.info("get all names etag = %s", resp.etag) - if req.if_match == resp.etag: - return HTTPNotModified() + if etag in req.if_none_match: + return exc.HTTPNotModified() resp.content_type = "application/json" resp.body_file.write("[") @@ -111,7 +114,7 @@ application = App() if __name__ == '__main__': from wsgiref.simple_server import make_server - httpd = make_server("localhost", 8080, application) + httpd = make_server("", 8080, application) try: httpd.serve_forever() except KeyboardInterrupt: