Skip to content

yoavram/manu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

manu

Everybody's a critic

This is the server repository. There is also an android repository. Check out the RESI API docs and mock server.

Setup and run

Dependencies

  1. Python, preferably version 2.7.3
  2. The python packagge installer pip. If you need it for windows and can get it to work try downloading it from here.
  3. The python virtual environment manager virtualenv.
  4. The heroku CLI toolbelt
  5. A heroku username and password
  6. To be a collaborator on the heroku manumanu app.

Setup

  1. Open a command line\terminal window.
  2. Login to heroku: heroku login
  3. Clone repo: git clone https://github.com/yoavram/manu.git
  4. Add heroku remote: heroku git:remote -a manumanu
  5. Create a local .env file with the configuration: heroku config -s | grep CLOUD >> .env
  6. Add a debug variable to the .env file: echo DEBUG=True >> .env
  7. Add a variable to tell foreman to output print messages to console: echo PYTHONUNBUFFERED=true >> .env
  8. Create a virtual environment using virtualenv: virtualenv venv
  9. Activate the virtual environment: On linux source venv/bin/activate/, on windows venv\Scripts\activate.bat
  10. Install python requirements: pip install -r requirements.txt

Run

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.

REST API

The main API URL is http://manumanu.herokuapp.com, or http://localhost:5000 if you are working locally.

Upload image

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 to name 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 in index.html or here:
{
      "image_id": "stam tmuna",
      "image_format": "png",
      "image_url": "http://res.cloudinary.com/hx5wzcyfc/image/upload/v1359814682/stam+tmuna.png"
}

List images

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"
    }
  ]
}

Image URL

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

Image thumbnail URL

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

About

Everybody's a critic

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages