summaryrefslogtreecommitdiff
path: root/snapmesh.py
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2015-02-21 16:27:24 +0100
committerTimo <Code-WvS@quantentunnel.de>2015-02-21 16:27:24 +0100
commit40f499401313ebcd9f1d679ed61954b306f738f3 (patch)
tree4cd444213b48fea088ae061c9f2f0cb8056afac2 /snapmesh.py
downloadsnapmesh-40f499401313ebcd9f1d679ed61954b306f738f3.tar.gz
snapmesh-40f499401313ebcd9f1d679ed61954b306f738f3.zip
first commit
Diffstat (limited to 'snapmesh.py')
-rwxr-xr-xsnapmesh.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/snapmesh.py b/snapmesh.py
new file mode 100755
index 0000000..d632a59
--- /dev/null
+++ b/snapmesh.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python2
+import snapext, os
+handler = snapext.SnapHandler
+
+data = dict()
+
+@handler.route('/')
+def main():
+ return 'Ich bin online!'
+
+@handler.route('/check')
+def key_in_data(key):
+ return key in data
+
+@handler.route('/get')
+def get_data(key):
+ return data[key] if key_in_data(key) else ''
+
+@handler.route('/put')
+def set_data(key, value):
+ data[key] = value
+
+@handler.route('/list')
+def list_data():
+ return '\n'.join(data.keys())
+
+@handler.route('/bye')
+def shutdown():
+ with open('data', 'w+') as _:
+ _.write(str(data))
+ exit(1)
+ #os.system('shutdown -hP now')
+
+if __name__ == '__main__':
+ if os.path.isfile('data'):
+ with open('data') as _:
+ s = _.read()
+ try:
+ data = eval(_.read())
+ except:
+ pass
+
+ snapext.main(handler, 80)