diff --git a/README.md b/README.md index cb2d2fa..94329c2 100644 --- a/README.md +++ b/README.md @@ -6,38 +6,35 @@ At the moment, it relies on some details that are specific of our radio (like the directory/format of the continous recording). - Implementation details ====================== -It is based on bottle, to get a minimal framework. Rest APIs are offered +It is based on bottle, to get a minimal framework. Simple APIs are offered through it, and the static site uses them. +Here are some examples of APIs usage + Create -------- - JSON = { - 'starttime-rec-1385231288390': '2013/11/23 19:32:49', - 'endtime-rec-1385231288390': '2013/11/23 19:32:49', - 'recid': 'rec-1385231288390', - 'name-rec-1385231288390': 'adasd', - 'op': 'new' - } + starttime-rec-1385231288390: 2013/11/23 19:32:49 + endtime-rec-1385231288390: 2013/11/23 19:32:49 + recid: rec-1385231288390 + name-rec-1385231288390: adasd + op: new Update ------- - JSON = { - 'starttime-rec-1385231288390': '2013/11/23 19:32:49', - 'endtime-rec-1385231288390': '2013/11/23 19:32:49', - 'recid': 'rec-1385231288390', ### VALID REC ID - 'name-rec-1385231288390': 'adasd', - 'op': 'update' - } + starttime-rec-1385231288390: 2013/11/23 19:32:49 + endtime-rec-1385231288390: 2013/11/23 19:32:49 + recid: rec-1385231288390 + name-rec-1385231288390: adasd + op: update + Delete ------ - JSON = { - 'recid': 'rec-1385231288390', ### VALID REC ID - 'op': 'delete' - } + + recid: rec-1385231288390 + op: delete diff --git a/server/server.py b/server/server.py index a233c21..ce9b339 100644 --- a/server/server.py +++ b/server/server.py @@ -6,17 +6,12 @@ from bottle import Bottle, request, static_file, redirect from techrec import Rec, RecDB class RecServer: - def __init__(self,host="127.0.0.1", port=8000): - self._host = host - self._port = port - + def __init__(self): self._app = Bottle() self._route() self.db = RecDB() - def start(self): - self._app.run(host=self._host, port=self._port, debug=True) def _route(self): ### This is the API part of the app @@ -55,11 +50,11 @@ class RecServer: print "Server:: Create request %s " % req starttime = "" - if req["starttime-"+req["recid"]] != "": + if req["starttime-" + req["recid"]] != "": starttime = datetime.datetime.strptime( req["starttime-"+req["recid"]] , "%Y/%m/%d %H:%M:%S") endtime = datetime.datetime.now() - if req["endtime-"+req["recid"]] != "": + if req["endtime-" + req["recid"]] != "": endtime = datetime.datetime.strptime( req["endtime-"+req["recid"]] , "%Y/%m/%d %H:%M:%S") @@ -165,7 +160,7 @@ class RecServer: # @route('/help') def help(self): - return "

help


\ + return "

help


\

/get, /get/, /get/

\

Get Info about rec identified by RECID

\ \ @@ -177,9 +172,6 @@ class RecServer:

/update

\

Not implemented.

" -""" - TESTs -""" if __name__ == "__main__": - c = RecServer(host="localhost") - c.start() + c = RecServer() + c._app.run(host="localhost", port="8000", debug=True, reloader=True)