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

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*~
*.pyc

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()

10
run Executable file
View File

@@ -0,0 +1,10 @@
#!./env/bin/python
from management import app
#print("sdf2")
#app.run(debug=True)
if __name__ == "__main__":
# if len(sys.argv) > 1 and sys.argv[1] == "build":
# freezer.freeze()
# else:
app.run(host='0.0.0.0', port=4444, debug=True)

4
static/jquery-3.2.0.min.js vendored Normal file

File diff suppressed because one or more lines are too long

16
templates/index.html Normal file
View File

@@ -0,0 +1,16 @@
<html>
<head>
<title>Management</title>
<script src="static/jquery-3.2.0.min.js" ></script>
</head>
<body>
<h1>My Management</h1>
<ul>
<li>
<a href="syslog"> syslog</a>
<a href="/"> root</a>
</li>
</ul>
<div style="white-space: pre-wrap;font:Courier, monospace; font-size:small; width:80em;background:#DDF">{{out.decode('utf-8')}}</div>
</body>