Skip to content

Instantly share code, notes, and snippets.

@0atman 0atman/ministore.py
Last active Oct 9, 2017

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

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
You can’t perform that action at this time.