- Users can create an account and log in.
- Users can post questions.
- Users can delete the questions they post.
- Users can post answers.
- Users can view the answers to questions.
- Users can accept an answer out of all the answers to his/her question as the preferred answer.
Step 1
Create directory
$ mkdir stackoverflow
$ cd stackoverflow
Create and activate virtual environment
$ virtualenv env
$ source env/bin/activate
Clone the repository here
or
git clone https://github.com/ogol254/stackoverflow
Install project dependencies
$ pip install -r requirements.txt
Step 2
Go to postgres terminal and create the following databases
Main database
# CREATE DATABASE database_name ;
Test database
# CREATE DATABASE test_database_name ;
Step 3
export FLASK_APP="run.py"
export APP_SETTINGS="development"
export DATABASE_URL="dbname='database_name' host='localhost' port='5432' user='postgres' password='root'"
export DATABASE_TEST_URL="dbname='test_database_name' host='localhost' port='5432' user='postgress' password='root'"
Step 4
$ python run.py
Step 5
$ nosetests app/tests
Method | Endpoint | Functionality |
---|---|---|
POST | /auth/signup | Create a user account |
POST | /auth/login | Sign in a user |
POST | /auth/logout | Sign out a user |
Method | Endpoint | Functionality |
---|---|---|
POST | questions | Post a question |
POST | /questions/int:ques_id/answers | post an answer to a question |
GET | /questions | Get a List of all questions |
GET | /questions/int:ques_id | Get a question using its id |
GET | /questions/str:username | Get all questions posted by a particular user |
GET | /questions/answers/most | Get the question with the most answers |
PUT | /questions/int:ques_id | Edit a question |
DELETE | /questions/int:ques_id | Delete a question using its id |
POST | /questions/int:ques_id/answers | Post an answer to a question |
PUT | /questions/int:ques_id/answers/int:ans_id | Edit an answer |
PUT | /questions/int:ques_id/answers/int:ans_id | Mark an answer as preferred |
PUT | /questions/int:ques_id/answers/int:ans_id/vote | Up/Downvote an answer |