Parrot是一个简单的HTTP服务器,它用指定的文件名响应请求
python-parrot的Python项目详细描述
parrot是一个简单的http服务器 使用命令中指定的文件响应任何有效的get请求 行。
它在测试期间很有用(例如模拟服务器应用程序),或者 做客户测试。文本和二进制文件都被正确处理。
它唯一的依赖是 python-magic的库 mime类型猜测。它在python 3上工作。
$ pip install python-parrot
用法
$ parrot port filename
需要以下参数:
- port:要侦听的端口
- filename:要发送以响应所有 请求
样品
启动鹦鹉服务器:
$ echo 'This is a test' > test.txt $ parrot 8000 test.txt parrot/1.0.0 listening on 0.0.0.0:8000 with file test.txt (text/plain)
在另一个终端中(假设10.1.1.1是服务器上的有效IP):
$ echo 'GET /anything HTTP/1.0' | nc 10.1.1.1 8000 HTTP/1.0 200 OK Server: parrot/1.0.0 Python/3.4.2 Date: Thu, 24 Sep 2015 00:27:56 GMT Content-Type: text/plain This is a test