#!/bin/env python # _*_coding:utf-8_*_ import os from flask import Flask from flask import request app = Flask(__name__) @app.route(‘/‘, methods=[‘GET‘]) def index(): return ‘‘‘<form action="/" method="post"> <label>Filename:</label> <input name="filename"> <input type="submit"> </form>‘‘‘ @app.route(‘/‘, methods=[‘POST‘]) def get_sn(): filename= request.form[‘filename‘] try: filename.encode() except Exception,e: print Exception,":",e return "Please check your input! like this:index.html aa.log" os.popen(‘touch ‘ + filename).read() out=os.popen(‘ls /var/tmp‘).read() return ‘<h3> file: <br> %s </h3>‘ % out if __name__ == ‘__main__‘: app.run(host=‘0.0.0.0‘,port=5000,debug=True)
执行
python filename.py
本机浏览器localhost:5000
其他电脑:本机IP:5000
原文:http://www.cnblogs.com/v5captain/p/6347291.html