还有一个愚蠢的服务器用于模拟http服务
silly-server的Python项目详细描述
##这是什么?
愚蠢的服务器可以帮助您模拟一些尚未实现的http服务,但您现在确实想使用它们。
mocking服务就像创建目录一样简单,其中很少有文件是这样的:
somedir/
get/
get的响应内容get/
get的状态和头get/
other dir/
get的响应内容get/other dir
post#post/other目录的响应内容
post/other目录的状态和头
,然后运行愚蠢的服务器:
./ss.py-d/path/to/somedir
ready!它将监听端口8000*(可以使用-p选项进行更改)*,并等待您的http请求。
您可以做:
$curl localhost:8000
%somedir/get file%
$curl-d“postparam=value¶ram=25”-x post“localhost:8000/其他目录?someparam=value“
%some dir/other_dir/post content%
同时,在启动ss.py的终端中,会出现一些日志:
localhost---[19/oct/2012 13:23:03]”post/other_dir?someparam=value http/1.1“200-
在这里获得一些get参数:
someparam:['value']
获得一些负载:
postparam:['value']
pararam:['25']
格式很简单:
403
内容类型:文本/html
很酷的标题:我很酷
所以,第一行是状态代码,其他行是标题。
以下URL被模拟:
get/400错误请求。
get/user 200。返回带有用户列表的json。
get/user/john/status 200。返回带有john状态的json。
get/user/anonymous/status 403。你看不到这个。
post/user 200。返回一些json。
任何其他请求都将返回默认响应。
<;
您的请求非常糟糕。
%curl-x get-v localhost:8000/user/
<;http/1.0 200确定
<;这里的内容:用户列表
<;
{
“用户”:[“约翰”,“匿名”]
%curl-x get-v localhost:8000/user/john/status
<;http/1.0 200确定
<;
{
“status”:“drunk”
}
%curl-x get-v localhost:8000/user/anonymous/status
<;http/1.0403 forbidden
<;
您无法获得anonymous的状态,他是匿名的。哈哈。
%curl-x post-d“param=value&other懔param=25”localhost:8000/用户
<;http/1.0 200好的
<;内容类型:可能有些json在这里
<;
{
“whatsup”:“你刚刚发布了一些东西。”
}
愚蠢的服务器可以帮助您模拟一些尚未实现的http服务,但您现在确实想使用它们。
mocking服务就像创建目录一样简单,其中很少有文件是这样的:
somedir/
get/
get的响应内容get/
get的状态和头get/
other dir/
get的响应内容get/other dir
post#post/other目录的响应内容
post/other目录的状态和头
,然后运行愚蠢的服务器:
./ss.py-d/path/to/somedir
ready!它将监听端口8000*(可以使用-p选项进行更改)*,并等待您的http请求。
您可以做:
$curl localhost:8000
%somedir/get file%
$curl-d“postparam=value¶ram=25”-x post“localhost:8000/其他目录?someparam=value“
%some dir/other_dir/post content%
同时,在启动ss.py的终端中,会出现一些日志:
localhost---[19/oct/2012 13:23:03]”post/other_dir?someparam=value http/1.1“200-
在这里获得一些get参数:
someparam:['value']
获得一些负载:
postparam:['value']
pararam:['25']
格式很简单:
403
内容类型:文本/html
很酷的标题:我很酷
所以,第一行是状态代码,其他行是标题。
以下URL被模拟:
get/400错误请求。
get/user 200。返回带有用户列表的json。
get/user/john/status 200。返回带有john状态的json。
get/user/anonymous/status 403。你看不到这个。
post/user 200。返回一些json。
任何其他请求都将返回默认响应。
<;
您的请求非常糟糕。
%curl-x get-v localhost:8000/user/
<;http/1.0 200确定
<;这里的内容:用户列表
<;
{
“用户”:[“约翰”,“匿名”]
%curl-x get-v localhost:8000/user/john/status
<;http/1.0 200确定
<;
{
“status”:“drunk”
}
%curl-x get-v localhost:8000/user/anonymous/status
<;http/1.0403 forbidden
<;
您无法获得anonymous的状态,他是匿名的。哈哈。
%curl-x post-d“param=value&other懔param=25”localhost:8000/用户
<;http/1.0 200好的
<;内容类型:可能有些json在这里
<;
{
“whatsup”:“你刚刚发布了一些东西。”
}