36 lines
782 B
Python
Executable File
36 lines
782 B
Python
Executable File
#!/usr/bin/python2
|
|
from bottle import get, post, request, run, route, static_file, default_app
|
|
import json
|
|
import anydbm
|
|
|
|
data = anydbm.open("cryptopad.db", 'c');
|
|
|
|
@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>")
|
|
def delete(key):
|
|
if (data.has_key(key)):
|
|
del data[key]
|
|
|
|
@post("/storage/<key>")
|
|
def setItem(key):
|
|
data[key] = request.forms.get("value")
|
|
|
|
@get("/<filepath:path>")
|
|
def mystatic(filepath):
|
|
return static_file(filepath, root='static')
|
|
|
|
@route('/')
|
|
def index():
|
|
return static_file("cryptopad.html", root='static')
|
|
|
|
application=default_app()
|
|
|
|
if __name__ == "__main__":
|
|
run(application, host='localhost', port=55580)
|