Giter Club home page Giter Club logo

cpsc349-project4's Introduction

Mockroblog - Mock APIs for Microblogging

Q. What's the minimum amount of code needed to mock up a miniature Twitter back-end?

A. How comfortable are you with SQL?

Getting started

Use the following commands to get up and running.

In one terminal window:

$ sudo apt update                                               # updates package index
$ sudo apt install --yes ruby-foreman sqlite3                   # manage Procfile and database
$ sudo apt install --yes python3-pip python3-flask-cors         # required Python packages
$ python3 -m pip install sandman2                               # used to expose API
$ export PATH="$HOME/.local/bin:$PATH"
$ git clone https://github.com/ProfAvery/cpsc349-project4
$ cd cpsc349-project4/api
$ make                                                          # creates database
$ foreman start                                                 # starts back-end

In another terminal window:

$ cd cpsc349-project4/
$ npm install
$ npm start                                                     # starts front-end

You can examine the data using the sandman2 Admin Interface.

Tools

See the following references for more information:

Sample API calls

Operation HTTP Method URL
Create a user POST http://localhost:5000/users/
{
    "username": "tester",
    "email": "[email protected]",
    "password": "testing"
}
Operation HTTP Method URL
Check a user's password GET http://localhost:5000/users/?username=ProfAvery&password=password
Start following a user POST http://localhost:5000/followers/
{
    "follower_id": 4,
    "following_id": 2
}
Operation HTTP Method URL
Stop following a user DELETE http://localhost:5000/followers/6

Note that 6 is the id of the entry in the followers table, not the user_id of either user.

Operation HTTP Method URL
Retrieve a user's timeline GET http://localhost:5000/followers/6
Retrieve the public timeline GET http://localhost:5000/followers/6
Search posts for a hashtag GET http://localhost:5000/posts/?text=%%%%23cpsc315%%
Post a new message POST http://localhost:5000/posts/
{
    "user_id": 4,
    "text": "First poast!"
}

Other features

This version of the Mockroblog database includes additional data not included in Project 3:

  • Likes
  • Direct Messages
  • Polls

The REST API exposed by sandman2 also allows additional types of queries against existing data. See the documentation for details.

cpsc349-project4's People

Contributors

profavery avatar andy-lopez avatar hoanh-vo avatar caracer1 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.