GithubHelp home page GithubHelp logo

photos's Introduction

photos

google photos django project

class Album:

    name = models.CharField
    user = models.ForeignKey(User
    created = models.DateTimeField(auto_now_add=True)
class Image
    url
    user
    title
    created
    albums = models.ManyToManyField('Album')

Task List:

  • show my images only (show images for a user)

  • create album for me

  • show my albums

  • add only my photos to albums (make sure api prevents adding to some other user's photos)

api path: http://127.0.0.1:8000/api/v1/

APIs:

/image/
/album/
/user/

INSTALLATION:

git clone https://github.com/drake01/photos
cd photos
python3 -m venv env
source env/bin/activate
pip install -r requirements.txt
python ./manage.py migrate
python ./manage.py runserver

using "httpie":

  • create users: abc and xyz:
http POST http://127.0.0.1:8000/api/v1/user/ [email protected] username=abc password=abc

http POST http://127.0.0.1:8000/api/v1/user/ [email protected] username=xyz password=xyz
  • create some images
http -a abc:abc POST http://127.0.0.1:8000/api/v1/image/ title="abc image" url="abc url"
http -a abc:abc POST http://127.0.0.1:8000/api/v1/image/ title="abc image2" url="abc url2"
  • create some images for user: xyz
http -a xyz:xyz POST http://127.0.0.1:8000/api/v1/image/ title="xyz image" url="xyz url"
http -a xyz:xyz POST http://127.0.0.1:8000/api/v1/image/ title="xyz image2" url="xyz url2"
  • create albums:
http -a abc:abc POST http://127.0.0.1:8000/api/v1/album/ name="abc album"
http -a abc:abc POST http://127.0.0.1:8000/api/v1/album/ name="abc album2"
http -a xyz:xyz POST http://127.0.0.1:8000/api/v1/album/ name="xyz album"
  • add image to some albums using:
http -a user:password PUT http://127.0.0.1:8000/api/v1/image/<image_id>/ albums:='[list of album ids]' title='new image title'

For example,image 2 should be added to 3 albums with ids 1,2,3 and change title="new image title" Client request:

http -a abc:abc PUT http://127.0.0.1:8000/api/v1/image/2/ albums:='[1,2,3]' title='new image title'

GET requests:

  • show images:
http -a abc:abc GET http://127.0.0.1:8000/api/v1/image/

http -a xyz:xyz GET http://127.0.0.1:8000/api/v1/image/
  • returns 403 without -a user:password
http GET http://127.0.0.1:8000/api/v1/image/
  • show albums:
http -a abc:abc GET http://127.0.0.1:8000/api/v1/album/

http -a xyz:xyz GET http://127.0.0.1:8000/api/v1/album/

photos's People

Contributors

drake01 avatar gkr01 avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.