27 lines
678 B
Python
27 lines
678 B
Python
# -*- coding: utf-8 -*-
|
|
from flask import Flask,jsonify,send_from_directory, render_template
|
|
import subprocess
|
|
|
|
app = Flask(__name__, template_folder="templates", static_folder="static")
|
|
def run_cmd(cmd):
|
|
p = subprocess.Popen(cmd, stdout = subprocess.PIPE,
|
|
stderr=subprocess.PIPE,
|
|
stdin=subprocess.PIPE)
|
|
out,err = p.communicate()
|
|
return render_template("index.html",out=out)
|
|
|
|
|
|
@app.route("/")
|
|
def hello():
|
|
cmd = ["ls","-l"]
|
|
return run_cmd(cmd)
|
|
|
|
@app.route("/syslog")
|
|
def syslog():
|
|
cmd = ["tail","-n 200", "/var/log/syslog"]
|
|
return run_cmd(cmd)
|
|
|
|
|
|
#if __name__ == "__main__" :
|
|
# app.run()
|