Switched to cleaner bottle usage style

This commit is contained in:
ultra
2012-03-01 19:45:41 -05:00
parent 7432d55ce0
commit ed418464ce

View File

@@ -1,35 +1,36 @@
#!/usr/bin/python2
from bottle import get, post, request, run, route, static_file, default_app
import bottle
import json
import anydbm
app = bottle.Bottle()
data = anydbm.open("cryptopad.db", 'c');
@get("/storage/<key>")
@app.get("/storage/<key>")
def getItem(key):
if (data.has_key(key)):
return json.dumps(data[key])
else:
return json.dumps(None)
@get("/storage/delete/<key>")
@app.get("/storage/delete/<key>")
def delete(key):
if (data.has_key(key)):
del data[key]
@post("/storage/<key>")
@app.post("/storage/<key>")
def setItem(key):
data[key] = request.forms.get("value")
data[key] = bottle.request.forms.get("value")
@get("/<filepath:path>")
@app.route("/<filepath:path>")
def mystatic(filepath):
return static_file(filepath, root='static')
return bottle.static_file(filepath, root='static')
@route('/')
@app.route('/')
def index():
return static_file("cryptopad.html", root='static')
application=default_app()
return bottle.static_file("cryptopad.html", root='static')
if __name__ == "__main__":
run(application, host='localhost', port=55580)
bottle.debug(True)
bottle.run(app, host='localhost', port=55580)