Example defang API Server
Project description
Defang API
Defang API runs a local server or Docker that can assist in defanging URLs to make them safe to post in various apps or tp log in case logs.
Capabilities:
- Defang URL
- Refang URL
- Base64 Decode
- Base64 Encode
The defang functionality is ran using a a modified version of the defang package from Johan Nestaas. I currently a pull request in to incorporate the changes I have made to it to better support more protocols and defanging options.
Original: https://bitbucket.org/johannestaas/defang/src/master/
Mine: https://bitbucket.org/zpriddy/defang/src/master/
Pull Request: https://bitbucket.org/johannestaas/defang/pull-requests/4/add-better-support-for-defanging/diff
Installing and Running
Using PIP (Easy)
Install
Run : pip install defang-api
Running
Run: defang-server
By default this will run on localhost
on port 5000
but that can be changed at runtime:
defang-server --port=8080 --host-0.0.0.0
Using Docker (Advanced)
Install
Requirements:
- Docker Installed
brew install docker
- Docker Compose installed
brew install docker-compose
Clone the repo: git clone https://github.com/zpriddy/defang_api.git
Running
Run: cd defang_api
Run: docker-compose up
Using Defang API
When you launch the server by default it will run on localhost:5000
.
There is full Swagger documentation if you point your browser at
http://localhost:5000
. This will give you full details on all of the available options for each
endpoint of the API as well as the ability to test each of the endpoints.
By default the API will return its results in JSON but if accept
header is set to text/plain
then it will return the results in plain text.
Examples
If you run:
curl -X GET "http://localhost:5000/api/defang?url=http%3A%2F%2Fexample.com" -H "accept: text/plain"
You will get back
hXXp://example[.]com
curl -X GET "http://localhost:5000/api/defang?url=http%3A%2F%2Fexample.com" -H "accept: application/json"
Will give you back JSON:
{
"error": [],
"output": "hXXp://example[.]com"
}
If you have a list of URLS:
curl -X POST "http://localhost:5000/api/defang" -H "accept: application/json" -H "Content-Type: "\
"application/json" -d "{ \"colons\": false, \"dots\": false, \"url\": [ \"https://example.com\", \"https://foo.bar\" ]}"
Will give you:
{
"error": [],
"output": [
"hXXps://example[.]com",
"hXXps://foo[.]bar"
]
}
But if you set the accept to text/plain
you will get:
hXXps://example[.]com,hXXps://foo[.]bar
Notes
The simple GET
method endpoints are limited on the scope of options that there are in passing
data in. For this reason I recommend using the POST
method endpoints
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
Built Distribution
File details
Details for the file defang_api-0.0.1.tar.gz
.
File metadata
- Download URL: defang_api-0.0.1.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23c5eebb1e96d6de2b8328fa4dda74e430eddb2c2cc69608b98f81d09cdf0612 |
|
MD5 | e424aea2cc030d3a340d7b5cd515bc9c |
|
BLAKE2b-256 | 2a5c85438d8f43ee5cce9d2f3e0e0f9ecbda047ec0f767b17fce280a2f1a0a7d |
File details
Details for the file defang_api-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: defang_api-0.0.1-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | efc137f401e70b3854a0fc0543fc8721e50fa832bad431b386dc7501e7a72ffc |
|
MD5 | 3245d246b94d1c515c4493c052f2a9c2 |
|
BLAKE2b-256 | 833f4baf60d87447c0b57a6eacd19878aa0e43cdd74d407f695ade8f9ec14982 |