Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

No project description provided

Project description

ynm3k取名自”要你命3000”,目前的功能包括

  • 一个通过完全通过json进行配置的mock调试/反向代理服务器
  • 一个静态文件服务器(除静态目录外,还可以服务zip文件)

安装方法

通过pip安装

sudo pip install ynm3k

基本的使用方法

在8080启动一个mock服务器,根据mock.json的规则进行转发和改写请求

y3k --mock mock.json --port 8080

mock.json的一些例子如下所示:

  • 根据前缀转发请求至不同服务器

    [
      ["/api/", "http://example.com/api/"],
      ["/static/my_work.html", "http://127.0.0.1/static/my_work.html"],
      ["/", "http://192.168.1.10:8080/"]
    ]
    
  • 为每个请求增加一个特殊的header,比如设置X-Forwarded-For

    [
     [{"type": "prefix",
       "path": "/",
       "headers": {"X-Forwarded-For": "1.2.3.4"}},
      {"type": "remote",
       "url": "https://ifcfg.cn/"}
     ]
    ]
    
  • 转发某个前缀下的请求到一个本地目录下,并且对于/prefix/dirname/这样的请求自动返回该目录下的index.html的内容

    [
    ["/prefix/", {"type": "static",
                  "path": "examples/dir",
                  "try_files": "index.html"}
    ]
    ]
    
  • 为每个请求的response,增加一个特殊的header,比如设置Cache-Control

[
   [
      "/",
      {
         "type" : "remote",
         "url" : "https://ifcfg.cn/",
         "headers" : {
            "Cache-Control" : "private"
         }
      }
   ]
]
  • 改写特殊的请求(对于POST /test 这个请求,结果是文件test.json的内容)

    [
       [
     {
       "type": "exact",
       "path": "/test",
       "method": "POST"
     },
     {
       "type": "file",
       "body": "test.json",
       "headers": {"content-type": "json"}
     }
       ],
       ["/", "http://192.168.1.10:8080/"]
    ]
    

Project details


Release history Release notifications

History Node

0.4.6

History Node

0.4.5

History Node

0.4.4

History Node

0.4.2

History Node

0.4.1

History Node

0.4.0

History Node

0.3.3

History Node

0.3.2

History Node

0.3.1

This version
History Node

0.3.0

History Node

0.2.3

History Node

0.2.2

History Node

0.2.1

History Node

0.2.0

History Node

0.1.11

History Node

0.1.10

History Node

0.1.9

History Node

0.1.8

History Node

0.1.7

History Node

0.1.6

History Node

0.1.5

History Node

0.1.4

History Node

0.1.3

History Node

0.1.2

History Node

0.1.1

History Node

0.1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
ynm3k-0.3.0.tar.gz (52.4 kB) Copy SHA256 hash SHA256 Source None Sep 14, 2017

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page