Files
cryptopad/server.py
2023-03-15 19:27:25 -04:00

38 lines
781 B
Python
Executable File

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