StackOverflow-Lite is an app that allows a user to post questions, answer other questions posted on the forum. Users can accept answers to their questions and view various statistics involved such as the number of questions asked or answered.
The api provides endpoints for signup, login, logout, retrieve all or a single question, post a question, answer a question and update an answer or accept an answer.
http methods | Endpoint route | Endpoint functionality |
---|---|---|
POST | /api/v1/auth/signup | Creates a user account |
POST | /api/v1/auth/login | Logs in a user |
POST | /api/v1/auth/logout | Logs out a user |
GET | /api/v1/questions | Get all questions on platform |
POST | /api/v1/questions | Post a new question |
GET | /api/v1/questions/<question_id> | Get a single question |
DELETE | /api/v1/questions/<question_id> | Delete a question |
POST | /api/v1/questions/<question_id>/answers | Post an answer |
GET | /api/v1/questions/<question_id>/answers | Get all answers for a question |
PUT | /api/v1/questions/<question_id>/answers/<answer_id> | Edit or accept an answer |
POST | /api/v1/questions/<question_id>/answers/<answer_id>/upvote | Upvote an answer |
POST | /api/v1/questions/<question_id>/answers/<answer_id>/downvote | Downvote an answer |
GET | /api/v1/users/questions | Get all questions asked by user |
POST | /api/v1/questions/<question_id>/answers/<answer_id>/comments | Post a comment |
GET | /api/v1/questions/<question_id>/answers/<answer_id>/comments | Get all comments for an answer |
PUT | /api/v1/questions/<question_id>/answers/<answer_id> | Edit comment |
/comments/<comments_id> | ||
POST | /api/v1/questions/search?limit=10 | Search a question |
pip
virtualenv
python 3
postgresql
PgAdmin (Optional)
```
$ psql postgres
postgres=# CREATE DATABASE db_stackoverflow_lite;
postgres=# CREATE DATABASE testdb;
```
Open Postgres PgAdmin and create 2 databases test_db and db_stackoverflow_lite
clone repo:
https://github.com/njeri-ngigi/stackoverflow_api.git
create virtual environment:
virtualenv <environment name>
activate environment:
$source <path to env name>/Scripts/activate (in bash)
install dependencies:
$pip install -r requirements.txt
To run the application:
$python run.py
The tests for this API are written using the python module unittests. The tests are found in the folder tests.
Use nose to run the tests.
To run the tests:
$nosetests tests/
To show coverage:
$nosetests tests/ --with-coverage
Go to Stackoverflow-Lite Documentation on apiary.io
The app is hosted on heroku
Go to Stackoverflow-lite
Flask, a python framework