messages: refactoring and REST API 

Refactoring of the messages module. An api.py file has been created in order to interact with the database. Also a restful.py file has been created so that messages can have a REST API.
69: D290 White spaces around docstring should be trimmed.