Codes/Python

python Flask 입력받은 커맨드를 실행해주는 어플리케이션

2017. 12. 17. 02:31

연습삼아 만든 Flask 웹 어플리케이션


#!/usr/bin/python
# coding: utf-8

import commands
from flask import Flask, render_template

app = Flask(__name__)

@app.route('/')
def index():
    body = """the Site for running your command"""
    return body

@app.route('/command/')
@app.route('/command/<cmd>')
def command(cmd=None):
    if cmd != None:
        output = commands.getstatusoutput(cmd)[1]
        return output
    else :
        return "Please input your command"


if __name__ == "__main__":
    app.run(host='0.0.0.0', debug=True)


ㅁㄴㅇㄹ