management init
This commit is contained in:
26
__init__.py
Normal file
26
__init__.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# -*- 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()
|
||||
Reference in New Issue
Block a user