From b9d27571ef89a9a0a4b9ba4e9bdf001467989598 Mon Sep 17 00:00:00 2001 From: karim hamidou Date: Thu, 12 Jul 2012 10:20:48 +0200 Subject: [PATCH] made the interface more restful --- cagibi/server.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/cagibi/server.py b/cagibi/server.py index 354ecc6..c115bb1 100644 --- a/cagibi/server.py +++ b/cagibi/server.py @@ -1,4 +1,4 @@ -from bottle import Bottle, route, run, post, request, abort +from bottle import Bottle, route, run, post, put, delete, request, abort import os, time import json from config import load_config, save_config @@ -17,13 +17,13 @@ def filelist(): return json.dumps(dir) -@post('/create/') -def create_file(): +@put('/files/') +def create_file(filename): """Create a file on the server. The method receives two POST parameters: - filename : the filename - contents : the contents """ - filename = os.path.basename(request.forms.get('filename')) + filename = os.path.basename(filename) contents = request.forms.get('contents') # FIXME: possible race condition @@ -37,11 +37,10 @@ def create_file(): else: abort(501, "File already exists") -@post('/delete/') +@delete('/files/') def delete_file(filename): """Remove a file""" filename = os.path.basename(filename) - print filename # FIXME: possible race condition if os.path.exists(filename) and filename in files_info: @@ -53,7 +52,7 @@ def delete_file(filename): abort(501, "File doesn't exist or is not in database.") -@post('/update/') +@post('/files/') def update_filename(filename): """return the deltas corresponding to the file. The client must send in its request the hashes of the file""" return filename -- 2.43.0