This is the server repository. There is also an android repository. Check out the RESI API docs and mock server.
- Python, preferably version 2.7.3
- The python packagge installer pip. If you need it for windows and can get it to work try downloading it from here.
- The python virtual environment manager virtualenv.
- The heroku CLI toolbelt
- A heroku username and password
- To be a collaborator on the heroku manumanu app.
- Open a command line\terminal window.
- Login to heroku:
heroku login
- Clone repo:
git clone https://github.com/yoavram/manu.git
- Add heroku remote:
heroku git:remote -a manumanu
- Create a local
.env
file with the configuration:heroku config -s | grep CLOUD >> .env
- Add a debug variable to the
.env
file:echo DEBUG=True >> .env
- Add a variable to tell foreman to output print messages to console:
echo PYTHONUNBUFFERED=true >> .env
- Create a virtual environment using virtualenv:
virtualenv venv
- Activate the virtual environment: On linux
source venv/bin/activate/
, on windowsvenv\Scripts\activate.bat
- Install python requirements:
pip install -r requirements.txt
Run the server locally using Foreman: foreman start
.
You could also start it via python image_server.py
but it will not read the heroku configuration so you will not be connected to third-party services.
The main API URL is http://manumanu.herokuapp.com
, or http://localhost:5000
if you are working locally.
Used to upload a single image.
- Endpoint:
/image
- Method:
POST
- Post data:
name
, optional, an identifier for the image - Post files:
image
, mandatory, a single image file stream - Returns a JSON with the following keys:
image_id
: an identifier of the image. Save this to retrieve/delete the image later on. This is equal toname
if `name was given.image_url
: the URL of the image (may change, so save the ID not the URL)image_format
: the format (i.e.png
,jpg
) of the image. Save this to retrieve a correct image URL later on. See example in the form inindex.html
or here:
{
"image_id": "stam tmuna",
"image_format": "png",
"image_url": "http://res.cloudinary.com/hx5wzcyfc/image/upload/v1359814682/stam+tmuna.png"
}
Lists the images in the server.
- Endpoint:
/listImages
- Method:
GET
- No data or arguments
- Returns a JSON with a list names
images
of image details (image_id
,image_url
,image_format
).
Example:
{
"images": [
{
"image_id": "stam tmuna",
"image_format": "png",
"image_url": "http://res.cloudinary.com/hx5wzcyfc/image/upload/v1359814682/stam+tmuna.png"
},
{
"image_id": "logo2",
"image_format": "png",
"image_url": "http://res.cloudinary.com/hx5wzcyfc/image/upload/v1359814629/logo2.png"
},
{
"image_id": "logo1",
"image_format": "png",
"image_url": "http://res.cloudinary.com/hx5wzcyfc/image/upload/v1359812613/logo1.png"
}
]
}
Get the URL of an image.
- Endpoint:
image/<string:image_id>/<string:image_format>
- Method:
GET
- Returns a string of the URL
Example:
http://res.cloudinary.com/hx5wzcyfc/image/upload/ofer.jpg
Get the URL of a thumbnail for an image
- Endpoint:
thumbnail/<string:image_id>/<string:image_format>
- Method:
GET
- Returns a string of the URL