36 lines
874 B
Python
36 lines
874 B
Python
|
from __future__ import print_function
|
||
|
|
||
|
import sys
|
||
|
from wsgiref.simple_server import make_server
|
||
|
|
||
|
|
||
|
def main(sysargs=sys.argv[:]):
|
||
|
app = ShippingApp()
|
||
|
port = 18080
|
||
|
server = make_server('0.0.0.0', port, app)
|
||
|
print('serving {0.__class__.__name__} on port {1}'.format(app, port))
|
||
|
server.serve_forever()
|
||
|
return 0
|
||
|
|
||
|
|
||
|
class ShippingApp(object):
|
||
|
|
||
|
def __call__(self, environ, start_response):
|
||
|
start_response('200 OK', [('content-type', 'text/plain')])
|
||
|
return ['oker doke']
|
||
|
|
||
|
@classmethod
|
||
|
def get_shipping_options(cls, zipcode, pounds):
|
||
|
base_cost = (float(zipcode) / 10000.0) + (pounds * 5.0)
|
||
|
return {
|
||
|
"Next Day": int(base_cost * 4),
|
||
|
"Two Day Air": int(base_cost * 2),
|
||
|
"Saver Ground": int(base_cost)
|
||
|
}
|
||
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
sys.exit(main())
|
||
|
|
||
|
# vim:filetype=python
|