Skip to content

Instantly share code, notes, and snippets.

@0atman
Last active October 9, 2017 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0atman/ce14338b49e66414407f052bfd290466 to your computer and use it in GitHub Desktop.
Save 0atman/ce14338b49e66414407f052bfd290466 to your computer and use it in GitHub Desktop.
A thin rest wrapper around a python shelf
#!/usr/bin/blaze pex flask flask-restful --
import shelve
from flask import Flask, request
from flask_restful import Resource, Api
app = Flask(__name__)
api = Api(app)
with shelve.open('ministore.db') as db:
class MiniStore(Resource):
def get(self, key):
return {key: db[key]}
def put(self, key):
db[key] = request.form['data']
return {key: db[key]}
api.add_resource(MiniStore, '/<string:key>')
if __name__ == '__main__':
app.run()
@0atman
Copy link
Author

0atman commented Oct 9, 2017

To execute this script, use http://blaze.oat.sh/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment