看到一个python入门脚本 记录一下
from BaseHTTPServer import *
import base64, os
decorator = lambda x: x.rstrip("\n") + " (" + base64.b64encode(x.rstrip("\n")) + ")\n"
class Handler(BaseHTTPRequestHandler):
def process(self):
path = self.path.split('?')[0].split('#')[0][1:]
try:
cmd = base64.decodestring(path)
if cmd == "":
return "Command List: \n\n" + "".join(map(decorator, file("CommandList").readlines()))
except:
return "Try to access /[Base64 String]"
if cmd+"\n" in file("CommandList").readlines():
return os.popen(cmd, "r").read()
else:
return cmd + " is not permitted"
def do_GET(self):
self.send_response(200)
buf = self.process()
self.send_header("Content-Type", "text/plain; charset=utf8")
self.send_header("Content-Length", str(len(buf)))
self.end_headers()
self.wfile.write(buf)
httpd = HTTPServer(("", 10000), Handler)
print "Server starting ..."
try:
httpd.serve_forever()
except KeyboardInterrupt: exit()
地址:
http://xiaoxia.org/2011/08/16/a-small-python-program-serverinformation/
分享到:
相关推荐
Python记录键盘.rar
使用python记录按键信息,简单版本的监控
python-json-logger, 标准 python 记录器的Json格式化程序 概述这里库提供了允许标准 python 日志记录输出日志数据作为json对象的标准。 使用 JSON,我们可以让计算机更容易读取日志,并且可以停止为syslog类型记录...
主要介绍了python记录程序运行时间的三种方法的相关资料,需要的朋友可以参考下
行为数据记录_键盘输入_鼠标点击_鼠标位置_页面截图_Python记录浏览器操作
procSpy - 用于监视和记录Linux系统上用户运行命令的Python工具
今天小编就为大家分享一篇Python获取昨天、今天、明天开始、结束时间戳的方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
本文实例讲述了Python记录详细调用堆栈日志的方法。分享给大家供大家参考。具体实现方法如下: import sys import os def detailtrace(info): retStr = "" curindex=0 f = sys._getframe() f = f.f_back # ...
python零基础入门学习课程,主要包括windows...python结构语句(if判断语句和while循环语句和for循环语句),python的函数讲解等内容,文档共4万多字,是自己(小白)通过开源课程学习python记录的文档,算是做个纪念~
主要介绍了如何使用python记录室友的抖音在线时间,本文通过实例代码图文相结合给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
python3-logger-vs-logging 了解python记录器层次结构$ python src / main.py INFO:root: * main.py * INFO:root: * app.client imported * INFO:[app.client]: * app.client imported * INFO:root: * main.py: ...
rpi_i2c 在树莓派上用 python 记录传感器值
下面小编就为大家带来一篇用python记录运行pid,并在需要时kill掉它们的实例。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
leetcode 答案Leetcode-Python 用 Python 记录我的 leetcode 答案
记录器丰富的python记录器的简单设置
python的记录学习021.1Python语言1.1Python语言的基本概念1.2Python 的特色1.3Python的发展及应用2.搭建环境2.1Python的解释器2.2搭建Python环境2.3Python的交互模式2.4 pip工具的使用2.5Python的第一个程序3. ...
python实现的键盘记录器小功能代码 博客记录: https://lexsaints.blog.csdn.net/article/details/113736987
windows下,使用python2.7,持续ping目标地址,并显示实时ping的时间和结果,并实时保存txt到当前目录