Skip to main content

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/"]
    ]

Release files for ynm3k 0.4.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ynm3k 0.4.8
File Size Uploaded
ynm3k-0.4.8.tar.gz 55.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ynm3k 0.4.8
File Interpreter ABI Platform
ynm3k-0.4.8-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 115.5 kB

Release files / ynm3k-0.4.8.tar.gz

Download URL ynm3k-0.4.8.tar.gz
Size 55.5 kB
Tags Source
SHA-256 checksum
How to use checksums
995b176460248dccfa2c1506e6f2004508c15c142e3fdfb5c9525a2e56971052
BLAKE2b-256 checksum
How to use checksums
d470063dae4118d39bc9d14528127dd49a3689e37c1effb43b3a6fed3a69cb6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/3.5

Release files / ynm3k-0.4.8-py2.py3-none-any.whl

Download URL ynm3k-0.4.8-py2.py3-none-any.whl
Size 60.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
fcc984ecdeac12a1488c408b401c311e83d2c4f0a545a5d85c1cedd24fb352ba
BLAKE2b-256 checksum
How to use checksums
c3537e3b80176e812a24be609652f3407eeebc2cc348e9c6fec34ae11adf1902
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/3.5

Release history Release notifications | RSS feed

This release

0.4.8 This release

2 release files

0.4.7

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

1 release file

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

1 release file

0.1.2

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page