Flask User API is built on Flask-restful to provide simple user management functionality.
Such as
- User creation
- User Login
- Facebook Login
- Password management
- Profile management
- Friend List management
- Simple Post
The API is currently deployed on Heroku
Flask User API stores data in mongodb. All user password is hashed using bcrypt. In order to access the main functionality, users need to use the token from login endpoint. The token is generated through itsdangerous and lives for certain time. User ID and token pair is cache in redis to reduce database query.
This is a list files or directories for flask user api
/api
- scripts implement actual api functions/model
- define database model/templates
- email templates/test
- simple test scripts using requests/util
- utilities for sending email, authorization, and serializationapp.py
- script to bootstrap the appconfig.py
- configuration for the appProcgile
- heroku server configurationrequirements.txt
- dependency file
pip install -r requirements.txt
change the arguments in config.py
python app.py
Create User
curl localhost:5000/create_user -X POST -d "email=123@gmail.com" -d "password=123"
Login
curl localhost:5000/login -X POST -d "email=123@gmail.com" -d "password=123"
FB Login
curl localhost:5000/fb_login -X POST -d "fbtoken=" -d "fbid="
Renew Token
curl localhost:5000/login -X GET --header "token: from login api"
Change Password
curl localhost:5000/change_password -X POST --header "token: from login api" -d "old_password=123" -d "new_password=1234"
Forget Password
curl localhost:5000/forget_password -X POST -d "email=123@gmail.com" -d "username=test" -d "school=UIUC"
Load Profile
curl localhost:5000/profile -X GET --header "token: from login api"
Edit Profile
curl localhost:5000/profile -X POST --header "token: from login api" -d "username=test" -d "school=UIUC" -d "intro=I am Frank"
Upload Profile Icon
curl --form upload=@icon.png --form press=OK localhost:5000/upload_profile_icon -X POST --header "token: from login api"
Search Profile
curl localhost:5000/search_profile -X GET --header "token: from login api" -d "school=UIUC"
Get Friends List
curl localhost:5000/friends_list -X GET --header "token: from login api"
Add to Friends List
curl localhost:5000/friends_list -X POST --header "token: from login api" -d "profile_id= "
Delete from Friends List
curl localhost:5000/friends_list -X DELETE --header "token: from login api" -d "profile_id= "
Get Friends Request List
curl localhost:5000/friends_request -X GET --header "token: from login api"
Post a Friend Post
curl localhost:5000/post -X POST --header "token: from login api" -d "content=I want to find someone to talk"
Get posts
curl localhost:5000/post -X GET --header "token: from login api"
Just create a new heroku application, and push the code to heroku
heroku create
git push heroku
heroku ps:scale web=1
This project is built on following libraries