json-server.py
Fake REST API with zero coding.
This project is heavily inspired by json-server in JavaScript.
Requires Python 3.6+.
Installation
It's highly recommended to install with pipx.
$ pipx install json-server.py
Or install with pip at your own risk:
$ pip3 install json-server.py
Get Started
Create a db.json file with following content:
{
"posts": []
}
Start a server:
$ json-server db.json
Create a post:
$ curl -H 'content-type: application/json' -d '{"content":"blablabla"}' http://localhost:3000/posts
List all posts:
$ curl http://localhost:3000/posts
Usage
Usage: json-server [OPTIONS] [FILENAME]
Start a JSON server.
FILENAME refers to the JSON file where your data is stored. `db.json` will
be used if not specified.
Options:
--version Show the version and exit.
-b, --bind TEXT Set address to bind, default as `:3000`
--help Show this message and exit.
Note:
- Collections must be contained in your data file before starting the server, otherwise the server cannot decide the type of resources.
Examples
# Start with default config
$ json-server
# Listen on port 3000
$ json-server -b :3000
# Specify a json file
$ json-server db.json
Release files for json-server-py 0.1.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| json_server_py-0.1.11.tar.gz | 4.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| json_server_py-0.1.11-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.0 kB
Release files / json_server_py-0.1.11.tar.gz
| Download URL | json_server_py-0.1.11.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fb9d6ce9e08d6ebd75e164298055a74e35a6ab9e8ea3f8f537cb6fbc9ca77c7a
|
|
BLAKE2b-256 checksum How to use checksums |
e1bc9d4ee6f74537d0addcface24cb269978232717dd3e6dd4d811e7dede1501
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.2 CPython/3.10.2 Linux/5.15.0-1020-azure
|
Release files / json_server_py-0.1.11-py3-none-any.whl
| Download URL | json_server_py-0.1.11-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c085f07b08393e94f1ff7966fd8b4a1fcaf8ff9529e2f76860513d0fd8524130
|
|
BLAKE2b-256 checksum How to use checksums |
d3b186436f699df0c63120f73b7a017c4d7d95ab8afd14b3edcdefe1289aa7cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.2 CPython/3.10.2 Linux/5.15.0-1020-azure
|