Rest API to convert openwrt config to json and vice versa using flask
Project description
netjson-rest
A simple flask rest API's to convert from json config to openwrt and vice versa
The code is Python 2, but Python 3 compatible.
Installation
Fast install:
::
pip install -i https://test.pypi.org/simple/ netjson-rest
For a manual install get this package:
::
wget git@github.com:umeshahp/netjson-rest.git
unzip master.zip
rm master.zip
cd netjson-rest
Install the package:
::
python setup.py install
Example
To run python flaskRestAPI.py
Usage:
Call this to convert from json to openwrt : http://:6000//spanfi/api/v1/toopen_wrt
test.py
data = { "hostname" : "spanidea", "timezone" : "IST", "radios" : [{ "name" : "Spanidea", "protocol" : "802.11ac" , "channel" : 36, "channel_width" : 20, "tx_power " : 10, "country" : "IN"
}
] , "wireless": [ { "name": "lo", "type": "wireless", "addresses": [ { "address": "127.0.0.1", "mask": 8, "proto": "static", "family": "ipv4" } ] } ] } x = request.post(data =data, url = 'http://:6000/spanfi/api/v1/toopen_wrt')
:: Call this to convert from openwrt to json : http://:6000/spanfi/api/v1/tojson multipart_form_data = { 'file2': ('custom_file_name.zip', open('myfile.zip', 'rb')), 'action': (None, 'store'), 'path': (None, '/path1') } x = request.post(data = data, url = 'http://:6000/spanfi/api/v1/tojson', files=multipart_form_data )
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for netjson_rest-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc524f244bad9ff4767cb6652a5f0caeaa9bd8c451a015fb37149ab59932992a |
|
MD5 | a5ff4ab2113960865a4717b37f4ddd42 |
|
BLAKE2b-256 | 7fb59eb3c0cad9f654a5ca1230f9635e5dcc52df1e30cfbddf302371c15f497b |