https://github.com/arudzinska/weirdtext
https://github.com/arudzinska/weirdtext
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/arudzinska/weirdtext
- Owner: arudzinska
- Created: 2019-03-30T16:44:52.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-06-10T21:19:15.000Z (almost 4 years ago)
- Last Synced: 2025-02-02T06:25:16.397Z (4 months ago)
- Language: Python
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# WeirdText encoder and decoder - Django REST API
Django REST app exposing two endpoints to encode text (any) or decode text (in the encoder
format).## Deployment
#### With runserver
1) Create a virtual environment and activate it. For Python3:
```
$ python3 -m venv $PATH_TO_VENV
$ source $PATH_TO_VENV/bin/activate
```2) Install modules:
```
$ pip3 install -r requirements.txt
```3) Runserver:
```
$ python manage.py runserver
```The app is running at http://127.0.0.1:8000.
#### With Docker
1) Run the bash script (may require `sudo` permissions):
```
$ ./build_and_run.sh
```The app is running at http://127.0.0.1:8000.
## API
There are two endpoints available:
* **/v1/encode****Method:** POST
**Data (body) Params:** text=Text to encode!
**Success Response:**
Code: 200
Content: "Encoded text"
**Error Response:**
Generated when request does not have the 'text' key in the body.
Code: 400
Content: "Some error message"
**Sample Call:**
$ curl --data 'text=For example... this text' -X POST http://localhost:8000/v1/encode
Output (example): `"\n-weird-\nFor epxlame... tihs txet\n-weird-\nexample text this"`
* **/v1/decode****Method:** POST
**Data (body) Params:** text=Encoded text in the WeirdText encoder format
**Success Response:**
Code: 200
Content: "Decoded text"
**Error Response:**
Generated when request does not have the 'text' key in the body.
Code: 400
Content: "Some error message"
**Sample Call:**
$ curl --data 'text=\n-weird-\nFor elpxame... tihs txet\n-weird-\nexample text this' -X POST http://localhost:8000/v1/decode
Output: `"For example... this text"`
## TestsCommand to run tests:
```
$ python manage.py test
```