Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mcomella/server-image-scale-sample
A quick sample of how a server might downscale images that are sent to it.
https://github.com/mcomella/server-image-scale-sample
Last synced: 12 days ago
JSON representation
A quick sample of how a server might downscale images that are sent to it.
- Host: GitHub
- URL: https://github.com/mcomella/server-image-scale-sample
- Owner: mcomella
- License: mpl-2.0
- Created: 2017-07-01T00:28:50.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-07-01T00:29:01.000Z (over 7 years ago)
- Last Synced: 2024-11-13T12:29:10.941Z (2 months ago)
- Language: Python
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# server-image-rescale
This is a quick sample of how a server might downscale images that are sent to
it.The server takes a POST request to `/` with the following *encoded* parameters:
* url: the url of an image you want the server to downscaledThe server will return the downscaled image.
## Setup
Run the following:
```sh
virtualenv -p python3 venv # Create virtualenv.
source venv/bin/activate # Start the virtualenv.
pip install -r requirements.txt # Install dependencies.
```## Running
With the virtualenv activated, run the server:```sh
FLASK_APP=main.py flask run
```By default, it will run at http://127.0.0.1:5000/.
## Testing the server
You can test the server with a curl request. For example, to request the server
to downscale, save the downscaled image to a file, and open it (on OS X), you
might call:```sh
curl --data "url=https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fcommons%2F8%2F8d%2FPresident_Barack_Obama.jpg" 127.0.0.1:5000/ > lol.png && open lol.png
```The server will return a downscaled version of [this
image](https://upload.wikimedia.org/wikipedia/commons/8/8d/President_Barack_Obama.jpg).