https://github.com/bitnom/aiounu
Asyncio module for unu in Python3 using aiohttp.
https://github.com/bitnom/aiounu
Last synced: about 1 year ago
JSON representation
Asyncio module for unu in Python3 using aiohttp.
- Host: GitHub
- URL: https://github.com/bitnom/aiounu
- Owner: bitnom
- License: mit
- Created: 2020-12-22T06:34:53.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-12-27T15:36:20.000Z (over 5 years ago)
- Last Synced: 2025-02-04T13:24:16.853Z (over 1 year ago)
- Language: Python
- Size: 51.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# aiounu
An asyncio module for [unu](https://u.nu/) in Python3 using aiohttp. Forked from
[vcinex/unu](https://github.com/vcinex/unu).
## Install
```sh
pip install aiounu
```
## Use
```python
import aiounu as unu
test_url = "https://example.com/?test=52e838e8-0943-4ccb-bfd8-ae6bb3173bd2"
unu_resp = await unu.shorten(url=test_url, output_format="dot", keyword="")
print(unu_resp.shorturl)
```
## Example Result
If `output_format` is set to **dot** (The default), the resulting JSON object properties will be accessible (Thanks to
[mo-dots](https://pypi.org/project/mo-dots/)) by both dot.notation and dict['notation'].
```json
{
"url": {
"keyword": "kfuns",
"url": "https://example.com/?test=52e838e8-0943-4ccb-bfd8-ae6bb3173bd2",
"title": "Example Domain",
"date": "2020-12-22 08:44:33",
"ip": "22.42.219.59"
},
"status": "error",
"message": "https://example.com/?test=52e838e8-0943-4ccb-bfd8-ae6bb[...] added to database
(Could not check Google Safe Browsing: Bad Request)",
"title": "Example Domain",
"shorturl": "https://u.nu/kfuns",
"statusCode": 200
}
```
Only the `url` variable is necessary. For a runnable example, see
[tests/test_shorten.py](https://github.com/TensorTom/aiounu/blob/master/tests/test_shorten.py) or clone the repo
and run [pytest](https://docs.pytest.org/en/stable/).
----------------------------------------
MIT License