Creating Armada service.
If you went through Getting Started series, you should already have a feel for how to operate services on Armada. In this guide we will show what is needed for the service to run on Armada smoothly and what problems Armada helps to solve. There are only a handful of steps needed to adapt your existing service to run on Armada. If you want to create a service from scratch the easiest way is to use one of our templates, like:$ armada create my_fancy_service -b python
coffee-counter.py
from collections import Counter
import web
import json
coffees = Counter()
class Drink(object):
def POST(self, user, count):
coffees[user] += int(count)
return "{0}'s coffee count is now {1}.\n".format(user, coffees[user])
class Report(object):
def GET(self):
return json.dumps(coffees)
def main():
urls = (
'/drink/(.*)/(.*)', Drink.__name__,
'/report', Report.__name__,
)
app = web.application(urls, globals())
app.run()
if __name__ == '__main__':
main()