management init

This commit is contained in:
Andreas Stephanides
2017-04-17 01:17:15 +02:00
commit 67df39f401
5 changed files with 58 additions and 0 deletions

26
__init__.py Normal file
View 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()