2013-03-06 03:30:00 +04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public License,
|
|
|
|
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
|
|
|
# obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
|
|
|
import bottle
|
2013-03-07 01:59:19 +04:00
|
|
|
import logging
|
2013-03-06 03:30:00 +04:00
|
|
|
|
|
|
|
import stoneridge
|
|
|
|
|
|
|
|
|
|
|
|
@bottle.post('/email')
|
|
|
|
def email():
|
2013-03-07 01:59:19 +04:00
|
|
|
logging.debug('handling email')
|
2013-03-06 03:33:23 +04:00
|
|
|
r = bottle.request.forms
|
|
|
|
to = r.get('to')
|
2013-03-07 01:59:19 +04:00
|
|
|
logging.debug('to: %s' % (to,))
|
2013-03-06 03:33:23 +04:00
|
|
|
subject = r.get('subject')
|
2013-03-07 01:59:19 +04:00
|
|
|
logging.debug('subject: %s' % (subject,))
|
2013-03-06 03:33:23 +04:00
|
|
|
msg = r.get('message')
|
2013-03-07 01:59:19 +04:00
|
|
|
logging.debug('message: %s' % (msg,))
|
2013-03-06 03:30:00 +04:00
|
|
|
|
|
|
|
stoneridge.sendmail(to, subject, msg)
|
|
|
|
|
|
|
|
|
|
|
|
def daemon():
|
|
|
|
stoneridge.StreamLogger.bottle_inject()
|
2013-03-07 01:51:47 +04:00
|
|
|
bottle.run(host='0.0.0.0', port=2255)
|
2013-03-06 03:30:00 +04:00
|
|
|
|
|
|
|
|
|
|
|
@stoneridge.main
|
|
|
|
def main():
|
|
|
|
parser = stoneridge.DaemonArgumentParser()
|
|
|
|
parser.parse_args()
|
|
|
|
parser.start_daemon(daemon)
|