Last active
October 9, 2017 13:33
-
-
Save 0atman/ce14338b49e66414407f052bfd290466 to your computer and use it in GitHub Desktop.
A thin rest wrapper around a python shelf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To execute this script, use http://blaze.oat.sh/