refactor, tweak html layout

main
Bryce Allen 11 years ago
parent 6d585a39d8
commit 16df6773d9

@ -15,6 +15,11 @@
flex-direction: column; flex-direction: column;
} }
label {
font-weight: bold;
font-family: sans, sans-serif;
}
#output { flex: 99 1 auto; } #output { flex: 99 1 auto; }
</style> </style>
@ -47,11 +52,13 @@
</head> </head>
<body> <body>
<div class="flex"> <div class="flex">
<label for="item">Item:</label> <div>
<input id="item" type="text" size="20" /> <label for="item">Item:</label>
<br /> <input id="item" type="text" size="20" />
<button id="search">Find Quests and Monsters</button> <button id="search">Find quests!</button>
<br /> <a href="http://www.reddit.com/r/MonsterHunter/comments/2z4pz3/finding_the_best_quest_to_farm_an_item_python/">(output explanation)</a>
<textarea readonly="true" rows="10" cols="80" id="output"></textarea> </div>
<br />
<textarea readonly="true" rows="10" cols="80" id="output"></textarea>
</div> </div>
</body> </body>

@ -2,7 +2,7 @@
from flup.server.fcgi import WSGIServer from flup.server.fcgi import WSGIServer
import reward_webapp from mhapi_wsgi import application
if __name__ == '__main__': if __name__ == '__main__':
WSGIServer(reward_webapp.application).run() WSGIServer(application).run()

@ -12,6 +12,9 @@ import mhrewards
DB_VERSION = "20150313" DB_VERSION = "20150313"
PREFIX = "/mhapi/" PREFIX = "/mhapi/"
# good for testing, use 1 hour = 3600 for deployment
MAX_AGE = "60"
logging.basicConfig(filename="/tmp/reward_webapp.log", level=logging.INFO) logging.basicConfig(filename="/tmp/reward_webapp.log", level=logging.INFO)
@ -62,12 +65,12 @@ class App(object):
def find_item_rewards(self, req, resp): def find_item_rewards(self, req, resp):
version = "1" version = "1"
resp.cache_control = "max-age=60" etag = DB_VERSION + version
resp.etag = DB_VERSION + version resp.cache_control = "public, max-age=" + MAX_AGE
resp.etag = etag
self.log.info("etag = %s", resp.etag) if etag in req.if_none_match:
if req.if_match == resp.etag: return exc.HTTPNotModified()
return HTTPNotModified()
resp.content_type = "text/plan" resp.content_type = "text/plan"
@ -83,12 +86,12 @@ class App(object):
def get_all_names(self, req, resp): def get_all_names(self, req, resp):
version = "2" version = "2"
resp.cache_control = "max-age=60" etag = DB_VERSION + version
resp.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 etag in req.if_none_match:
if req.if_match == resp.etag: return exc.HTTPNotModified()
return HTTPNotModified()
resp.content_type = "application/json" resp.content_type = "application/json"
resp.body_file.write("[") resp.body_file.write("[")
@ -111,7 +114,7 @@ application = App()
if __name__ == '__main__': if __name__ == '__main__':
from wsgiref.simple_server import make_server from wsgiref.simple_server import make_server
httpd = make_server("localhost", 8080, application) httpd = make_server("", 8080, application)
try: try:
httpd.serve_forever() httpd.serve_forever()
except KeyboardInterrupt: except KeyboardInterrupt:
Loading…
Cancel
Save