Notify webservice
#! -*- coding: utf-8 -*-
# service.py
''' use this, we can make a webservice to support notify from anywhere.
need: web.py, notify-send
usage: python service.py 9123
curl http://youip:9123/notify?title=hello&content=hello-world
'''
import web
import commands
urls = (
'/notify', 'notify',
)
class notify:
def GET(self):
inp = web.input(title='',content='')
title = inp.title.encode('utf-8')
content = inp.content.encode('utf-8')
status, output = commands.getstatusoutput('notify-send "%s" "%s"' % (title, content))
return ''
if __name__ == '__main__':
app = web.application(urls, globals())
app.run()
Written by 灵小句
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Python
Authors
Related Tags
#python
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#