The project is a platform in which the users will be able to exchange knowledge through it. You can learn from playing the guitar to the basics of a programming language, in which there will be a knowledge exchange, meaning that since you will be teaching someone else, it is expected that you too will be learning from your study partner.
This platform is being developed by all participants in the Processos de Software course at UFRN.
This component is responsible for create an API for use in web and android versions of system being developed.
- Python 3
- Falcon
- MySQL
Api in development for the platform described above, includes the following methods:
URL | VERB | BODY | EXAMPLE | RESULT |
---|---|---|---|---|
/user | POST | JSON | { "name":"Example", "email":"example@example.com", "age":"21", "password":"123456" } |
Add a user |
/user/{id} | GET | empty | --- | Return a user by given id |
/user/{id} | DELETE | empty | --- | Delete user by id |
/user/{id}/interests | GET | empty | --- | Return all interests of user = id |
/user/{id}/skills | GET | empty | --- | Return all skills of user = id |
/user/email/{e-mail} | GET | empty | --- | Return a user by given email |
/user/info | POST | JSON | {"facebook": "http://www.facebook.com/example", "whatsapp": "84111111111", "id_user": "5"} | Insert user information by an user id |
/user/info | PUT | JSON | {"facebook": "http://www.facebook.com/example", "whatsapp": "84111111111", "id_user": "5"} | Update user information by an user id |
/user/info/{id} | GET | empty | --- | Return an specific user information |
/user/info/{id} | DELETE | empty | --- | Delete user info by an user id |
--- | --- | --- | --- | --- |
/users | GET | empty | --- | Return all users |
/users/infos | GET | empty | --- | Return all users information |
/users/interests | GET | empty | --- | Return all pair user-interest |
/users/interests | POST | JSON | { "id_user":"1", "id_skill":"2" } |
Add a User-Interest relation |
/users/skills | GET | empty | --- | Return all pair user-skill |
/users/skills | POST | JSON | { "id_user":"1", "id_skill":"2" } |
Add a User-Skill relation |
URL | VERB | BODY | EXAMPLE | RESULT |
---|---|---|---|---|
/user/picture/{id_user} | GET | empty | --- | Return an url in format '/uploaded_pictures/filename.type' you might add server url before |
/user/picture | POST | JSON | { "type": "imagetype (png OR jpg OR gif)", "bytecode": "imagebase64bytecode", "id_user": 1 } |
Upload an image on server to a given user |
URL | VERB | BODY | EXAMPLE | RESULT |
---|---|---|---|---|
/login | POST | JSON | { "email":"example@example.com", "password":"123456" } |
Return HTTP status OK (200) if user logged correctly and HTTP status 403 if not |
URL | VERB | BODY | EXAMPLE | RESULT |
---|---|---|---|---|
/skill/ | GET | empty | --- | Return all skills |
/skill/{id} | GET | empty | --- | Return a skill by given id |
/skill/autocomplete/{name} | GET | empty | --- | Return all skills that contains {name} |
/skill/{id}/users | GET | empty | --- | Return all users that has skill id |
/user/{id}/skills | GET | empty | --- | Return all skills of user = id |
/users/skills | POST | JSON | { "id_user":"1", "id_skill":"2" } |
Add a User-Skill relation |
URL | VERB | BODY | EXAMPLE | RESULT |
---|---|---|---|---|
/interest/{id}/users | GET | empty | --- | Return all users that has interest id |
/user/{id}/interests | GET | empty | --- | Return all interests of user = id |
/users/interests | POST | JSON | { "id_user":"1", "id_skill":"2" } |
Add a User-Interest relation |
URL | VERB | BODY | EXAMPLE | RESULT |
---|---|---|---|---|
/matches | GET | empty | --- | Return all matches |
/matches/{id} | GET | empty | --- | Return all matches for an giver user_id |
/matches | POST | JSON | { "id_user_not":"16", "id_user_has":"1ad8", "id_skill": "2" } |
Insert a match |
To use the api server you will need Python 3, Falcon and a WSGI Server (in our project we use gunicorn).
To run our api server you will need to do this following steps one time:
- Install python-pip and mysql-server if you don't have it;
- Install the mysql client lib if you don't have it:
sudo apt-get install libmysqlclient-dev
; - Install python mysql lib:
# pip install MySQL-python
; - Install falcon using pip:
# pip install falcon
; - Install gunicorn using pip:
# pip install gevent gunicorn
.
For easier management of pip packages, it's recommended to use virtualenv. It creates isolated Python environments, and does not need superuser privileges to install packages.
To run the api server do the following:
- Clone the project:
$ git clone git@github.com:Processos-de-software-2016-2/python-api.git
; - Run the server:
gunicorn main:app --bind 0.0.0.0:<desired_port>
; - Make a HTTP request on port 8000 to any of the URLs listed in API Description section.
- Clone the project:
$ git clone git@github.com:Processos-de-software-2016-2/python-api.git
; - If you already have the project update it:
$ git pull origin master
; - Create a branch to start coding:
$ git checkout -b <branch_name>
; - Commit and push your changes:
$ git push origin <branch_name>
; - Create a pull request from your branch to master.