Created
December 18, 2018 09:39
-
-
Save converge/4a9e45f551ab3b9dacad0b278f8bf421 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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