-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
94 lines (70 loc) · 4.67 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
CPSC 449 WEB BACK-END ENGINEERING PROJECT 5- FALL 2020
Project by:
1. Ankita Udaykumar Kulkarni – CWID 887871861, Email- ankitak@csu.fullerton.edu
2. Aditi Pratap Patil – CWID 887465649, Email – aditipatil138@csu.fullerton.edu
Project Description:
This is a web back-end project in which three microservices are created:
1. Direct Message
2. Users
3. Timeline
These microservices are created for a microblogging service. This project has used Python Flak, SQLite3 Database and DynamoDB. The Direct Message microservice includes send direct message, reply to direct message, list messages and list replies. The User microservice includes creating user, authenticating user, add followers, remove followers. Timeline microservice posts a post on timeline, displays post of the user, displays post of all the follower’s user follows, Displays post of the all the users.
Steps to run the project: To run this project on Tuffix OS-
1. Install python3
$ sudo apt-get install python3.8
2. Install pip
$ sudo apt install python3-pip
3. Install Flak API and pugsql
$ sudo apt update
$ python3 -m pip install Flask-API pugsql
4. Install Foreman and HTTPie
$ sudo apt install --yes ruby-foreman httpie
5. Setting up DynamoDB Local:
1. Download DynamoDB for free using one of the following links from the following website: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.DownloadingAndRunning.html
2. After you download the archive, extract the contents and copy the extracted directory to a location of your choice.
3. To start DynamoDB on your computer, open a command prompt window, navigate to the directory where you extracted DynamoDBLocal.jar, and enter the following command.
$ java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb
6. Clone the GitHub repository
https://github.com/ankitakulkarnigit/MicrobloggingService.git
7. Configure AWS CLI
$ sudo apt update
$ sudo apt install –yes awscli
$ aws configure
AWS Access Key ID [None]: fakeMyKeyId
AWS Secret Access Key [None]: fakeSecretAccessKey
Default region name [None]: us-west-2
Default output format [None]: table
8. Install Boto3
$ sudo apt install –yes python3-boto3
9. Adding the DynamoDB Flask extension
$ python3 -m pip install –user flask-dynamo
10. cd to MicrobloggingService dir and run following commands:
$ FLASK_APP=app.py
$ flask init $ foreman start
After this we can see the three applications running on different ports. APIs can now be tested using the curl commands mentioned below or in app.py.
1. Direct Message
i. Send Direct message:
$ curl -i -X POST -H 'Content-Type:application/json' –d '{"to":"ankita", "from":"aditi", "message":"How are you?"}'http://localhost:5200/sendMessage;
ii. Reply to Direct message:
$ curl -i -X POST -H 'Content-Type:application/json' –d '{"messageId":"00bf7f51-4636-4008-80fe-f65d925c17ab", "reply":"I am fine"}'http://localhost:5200/reply;
iii. List Direct Message for user:
$ curl -i -X GET -H 'Content-Type:application/json' -d '{"username":"Rick"}'http://localhost:5200/list/messages;
iv. List Replies to message id:
$ curl -i -X GET -H 'Content-Type:application/json' -d '{"messageId":"9d529dd4-548b-4258-aa8e-23e34dc8d48i"}'http://localhost:5200/list/replies;
2. User
i. Create a new user:
$ curl -i -X POST -H 'Content-Type:application/json' -d '{"usernameAPI":"newuser", "emailAPI":"newuser@gmail.com", "passwordAPI":"newuser@123"}' http://localhost:5000/createUser;
ii. Authenticate an existing post:
$ curl -i -X GET -H 'Content-Type:application/json' -d '{"usernameAPI":"ankita", "passwordAPI":"ankita@123"}' http://localhost:5000/authenticateUser;
iii. Follow an existing user:
$ curl -i -X POST -H 'Content-Type:application/json' -d '{"usernameAPI":"om", "usernameFollowingAPI":"ankita"}' http://localhost:5000/addFollower;
iv. Remove an existing follower:
$ curl -i -X DELETE -H 'Content-Type:application/json' -d '{"usernameAPI":"om", "usernameFollowingAPI":"ankita"}' http://localhost:5000/removeFollower;
3. Timeline
i. Get user timeline:
$ curl -i -X GET -H 'Content-Type:application/json' -d '{"usernameAPI":"ankita"}' http://localhost:5100/getUserTimeline;
ii. Get public timeine:
$ curl -i -X GET http://localhost:5100/getPublicTimeline
iii. Get a home timeline:
$ curl -i -X GET -H 'Content-Type:application/json' -d '{"usernameAPI":"ankita"}' http://localhost:5100/getHomeTimeline;
iv. Post a tweet:
$ curl -i -X POST -H 'Content-Type:application/json' -d '{"usernameAPI":"ankita", "tweetAPI":"This is an example post"}' http://localhost:5100/postTweet;