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.10.tar.gz
(4.2 kB
view hashes)
Built Distribution
Close
Hashes for json_server.py-0.1.10-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43c19bdb1f3cace0dd7239cdaf88def34e637aa09cdc1d435cf52c9f17055ba5 |
|
MD5 | 1cb90c6b57052069e5c45ce5b19ebf87 |
|
BLAKE2b-256 | 6f174a6bff0c779ec6cd25e02aebcc03bbeea414230f1954594ab572a76b1a63 |