Skip to content

Instantly share code, notes, and snippets.

@converge
Created December 18, 2018 09:39
Show Gist options
  • Save converge/4a9e45f551ab3b9dacad0b278f8bf421 to your computer and use it in GitHub Desktop.
Save converge/4a9e45f551ab3b9dacad0b278f8bf421 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from flask import Flask
from flask import request
import subprocess
import shlex
app = Flask(__name__)
@app.route('/get_account_status', methods=['GET'])
def home():
account_name = request.args['account_name']
process = subprocess.Popen(shlex.split(
'python3 update_statistics.py -t {}'.format(account_name)),
stdout=subprocess.PIPE,
cwd='/home/xxx/xxx/xxx')
stdout = process.communicate()[0]
print("output: {}".format(stdout))
return stdout
@app.route('/test/<account_name>')
def some(account_name):
return 'ok {}'.format(account_name)
if __name__ == '__main__':
app.run(debug=True, host='server.address.here')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment