A simple JSON server
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
json_server_py-0.1.11.tar.gz
(4.3 kB
view details)
Built Distribution
File details
Details for the file json_server_py-0.1.11.tar.gz
.
File metadata
- Download URL: json_server_py-0.1.11.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.10.2 Linux/5.15.0-1020-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb9d6ce9e08d6ebd75e164298055a74e35a6ab9e8ea3f8f537cb6fbc9ca77c7a |
|
MD5 | ca1cc861aaa476b0e3b1f4cd953a73b6 |
|
BLAKE2b-256 | e1bc9d4ee6f74537d0addcface24cb269978232717dd3e6dd4d811e7dede1501 |
File details
Details for the file json_server_py-0.1.11-py3-none-any.whl
.
File metadata
- Download URL: json_server_py-0.1.11-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.10.2 Linux/5.15.0-1020-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c085f07b08393e94f1ff7966fd8b4a1fcaf8ff9529e2f76860513d0fd8524130 |
|
MD5 | ad4f863c022bdd758351b5c60ddcefe0 |
|
BLAKE2b-256 | d3b186436f699df0c63120f73b7a017c4d7d95ab8afd14b3edcdefe1289aa7cf |