https://github.com/kasim95/web_backend_project_1
APIs built using Python and SQLite to save, retrieve, filter posts, and votes for the posts.
https://github.com/kasim95/web_backend_project_1
api-rest python python3 sqlite
Last synced: about 1 month ago
JSON representation
APIs built using Python and SQLite to save, retrieve, filter posts, and votes for the posts.
- Host: GitHub
- URL: https://github.com/kasim95/web_backend_project_1
- Owner: kasim95
- License: mit
- Created: 2020-02-22T22:34:02.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-11T04:01:32.000Z (over 6 years ago)
- Last Synced: 2025-01-19T18:51:41.642Z (over 1 year ago)
- Topics: api-rest, python, python3, sqlite
- Language: Python
- Homepage:
- Size: 80.1 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# CPSC 449 Web Backend Engineering
## Project-1
### Project Members:
* Raj Chhatbar (chhatbarraj@csu.fullerton.edu) | Role: Ops
* Mohammed Kasim Panjri (kasimp@csu.fullerton.edu) | Role: Dev 1 Post API
* Harlik Shah (shahharlik@csu.fullerton.edu) | Role: Dev 2 Vote API
#### ---------------------------------- Dev Ops-------------------------------------------
1) Use this code for generating 3 instance of foreman in a terminal
```
foreman start -m post=3,vote=3
```
2) In separate terminal run
```
ulimit -n 8192 && caddy
```
3) Then go to localhost:2015/posts or localhost:2015/votes
ex: to get all post in Database run
http://localhost:2015/posts/filter
#### ---------------------------------- Post API-------------------------------------------
1. Create a new post: Send a POST request to route of create_post() fn
>
```
Example request:
curl -i -X POST -H 'Content-Type:application/json' -d '{"title":"Test post", "description":"This is a test post", "username":"some_guy_or_gal", "community_name":"449"}' http://localhost:2015/posts/create;
```
2. Delete an existing post: Send a GET request to route of delete_post() fn
```
Example request:
curl -i -X DELETE http://localhost:2015/posts/delete?post_id=4;
```
3. Retrieve an existing post: Send a GET request to route of get_post() fn
```
Example request:
curl -i http://localhost:2015/posts/get?post_id=2;
```
4. List the n most recent posts to a particular community: Send a GET request to route of get_posts_filter() fn with args (community_name and n)
```
Example request:
curl -i http://localhost:2015/posts/filter?n=2&community_name=calculus;
```
5. List the n most recent posts to any community: Send a GET request to route of get_posts_filter() fn with args (n)
```
Example request:
curl -i http://localhost:2015/posts/filter?n=2;
```
#### ---------------------------------- Vote API-------------------------------------------
1) Upvote a post:
```
Example request:
curl -i -X POST -H "Content-Type: application/json" -d '{"vote_id":"2"}' 'http://127.0.0.1:5000/upvotes'
```
2) Downvote a post:
```
Example request:
curl -i -X POST -H "Content-Type: application/json" -d '{"vote_id":"2"}' 'http://127.0.0.1:5000/downvotes'
```
3) Report the number of upvotes and downvotes for a post:
```
Example request:
curl -i 'http://localhost:2015/votes/get?vote_id=2';
```
4) List the n top-scoring posts to any community:
```
Example request:
curl -i 'http://localhost:2015/votes/getTop?n=3';
```
5) Given a list of post identifiers, return the list sorted by score.:
```
Example request:
curl -i -X POST -H "Content-Type: application/json" -d '{"post_ids":["1","3"]}' 'http://127.0.0.1:5000/getList'
```
## License
[MIT](https://choosealicense.com/licenses/mit/)