semvec/pypi-packages huggingface dataset:
jsonfind 0.1.2
search dict
License: MIT

# JSON(python dict) finder

## Install

- pip install jsonfind

## CLI

```
# jsonfind
Usage: jsonfind [OPTIONS] COMMAND [ARGS]...

Options:
  --version  Show the version and exit.
  --help     Show this message and exit.

Commands:
  find-any
  find-by
  find-eq
  find-is
  find-key
  find-regex
  find-subset

# jsonfind find-any --help
Usage: jsonfind find-any [OPTIONS] [OBJ]

Options:
  --verbose / --no-verbose
  --target TEXT                   query(JSON string)  [required]
  --format [jsonpath|jsonpointer]
  --key [eq|is|in1|in2|match|sub|eval|fnmatch|range]
  --value [eq|is|in1|in2|match|sub|eval|fnmatch|range]
  --mode [sub|super|set]
  --help                          Show this message and exit.
```

- jo hello=world a=$(jo b=$(jo c=d))
    - `{"hello":"world","a":{"b":{"c":"d"}}}`
- jo hello=world a=$(jo b=$(jo c=d)) | jsonfind find-eq --target $(jo c=d) --format jsonpointer
    - `["/a/b"]`
- jo hello=world a=$(jo b=$(jo c=d)) | ./bin/jsonfind find-eq --target $(jo c=d) --format jsonpath
    - `["a.b"]`
- jo hello=world a=$(jo b=$(jo c=d)) | ./bin/jsonfind find-by --format jsonpointer --query /a/b
    - `{"c": "d"}`
- jo hello=world a=$(jo b=$(jo c=d)) | ./bin/jsonfind find-by --format jsonpath --query a.b
    - `[{"c": "d"}]`

## Python

```
>>> from jsonfind import JsonFind
>>> obj = {"a":"b","c":{"d":"e"}}
>>> tgt = obj["c"]
>>> JsonFind.to_jsonpointer(JsonFind.find_eq(obj, tgt))
'/c'
>>> JsonFind.to_jsonpath(JsonFind.find_eq(obj, tgt))
'c'
```

# links

- [pypi repository](https://pypi.org/project/jsonfind/)
- [coverage report](https://wtnb75.github.io/jsonfind/)
- [local pypi repository](https://wtnb75.github.io/jsonfind/dist/)
pyserv 1.1.1
Python HTTPD Server to test GET and POST requests
License: MIT
Keywords: HTTPD SERVER,PYTHON HTTPD,SERVER,GET,REQUESTS,HTTPD

# HTTPD Python Server

## Installation and usage 

```python
pip install pyserv
```
```bash
serv [port]
```

## Examples :

```bash
serv 8080
```
The output would be 
```bash
...
INFO:root:Starting HTTP SERVER at PORT 8080
```

### GET and POST request example

Open a new terminal and try out sending GET and POST requests

```python
$ python
>>> import requests
>>> URL = 'http://0.0.0.0:8080'
>>> r = requests.get(URL)
>>> print(r.text)
GET request for /
```
On the server side you would get

```bash

INFO:root:GET  request,
Path: /
Headers:
Host: 0.0.0.0:8080
User-Agent: python-requests/2.21.0
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive



127.0.0.1 - - [18/Dec/2019 18:01:52] "GET / HTTP/1.1" 200 -

```


#### POST request to the server

```python

>>> import requests
>>> URL = 'http://0.0.0.0:8080'
>>> r = requests.post(URL)
>>> print(r.text)
POST request for /

```
On the server side you will get 

```bash
INFO:root:POST  request,
Path: /
Headers:
Host: 0.0.0.0:8080
User-Agent: python-requests/2.21.0
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive
Content-Length: 0



Body:


127.0.0.1 - - [18/Dec/2019 18:03:07] "POST / HTTP/1.1" 200 -

```
If no port is mentioned the server attempts to run on port 8080. 

If the given port (or the default port 8080) is already in use the server attempts to bind the next port. If the server does not find any free port after 50 attempts the server stops.

Link to the PyPI project : https://pypi.org/project/pyserv/
Motivation : https://gist.github.com/mdonkers/63e115cc0c79b4f6b8b3a6b797e485c7
(The Project is a extention of the github gist)