#!/bin/env python from flask import Flask, jsonify, request, abort import subprocess app = Flask(__name__) @app.route('/', methods=['POST']) def send_sms(): if not request.json or not 'phone' in request.json or not 'text' in request.json: abort(400) p = subprocess.run(['/usr/bin/sendsms', request.json['phone'], request.json['text']]) print(p.returncode) if p.returncode != 0: abort(400) else: return jsonify({'result': 'success'}), 201 if __name__ == '__main__': app.run(debug=True)