πΈπ€πΊ A Python tool to fake API server easily and humanly.
230
PyFake-API-Serverβ is a tool for faking API server easily and quickly by configuration only.
You need to configure a YAML file to set API details. Let's demonstrate a sample configuration for you:
mocked_apis:
foo_home:
url: '/foo'
http:
request:
method: 'GET'
response:
strategy: string
value: 'This is Foo home API.'
From above settings, it means setting an API:
This is Foo home API..And save above setting as file /User/foo/fake-server-demo/api.yaml.
Let's set up an instance to provide service:
docker run --name fake-server \
-v /User/foo/fake-server-demo:/mit-pyfake-api-server \
-p 9672:9672 \
-d \
pyfake-api-server:v0.1.0
Try to send a HTTP request to the service:
curl http://127.0.0.1:9672/foo
Congratulations! You successfully configure and set up a web server for faking API.
When you set up a PyFake-API-Server instance by Docker, you can pass one or more environment variables to set its settings.
CONFIG_PATH
This is an option variable. It would set the file path where it should use to configure the APIs and set up web server.
In default, its value is api.yaml.
WEB_FRAMEWORK
This is an option variable. The web framework PyFake-API-Server would use to set up web server to fake APIs. It only accepts 3 type values:
auto:
This is the default value. It would automatically detect which web framework PyFake-API-Server could use in current runtime environment.
flask:
Use Python web framework Flaskβ to set up web server.
fastapi
Use Python web framework FastAPIβ to set up web server.
WORKERS
This is an option variable. How many workers it should use to handle HTTP requests in the web server. In default, its value
is 1.
LOG_LEVEL
This is an option variable. Set the log level to let web server site show log message which is not below it. In default,
its value is info.
Content type
Image
Digest
sha256:9b6be9b49β¦
Size
434 MB
Last updated
over 1 year ago
docker pull chisanan232/pyfake-api-server:v0.4.2