Skip to content

Commit 3ff4216

Browse files
committed
Update READMES
1 parent 002a2e4 commit 3ff4216

File tree

2 files changed

+99
-102
lines changed

2 files changed

+99
-102
lines changed

backend/README.md

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Backend - Trivia API
22

3-
## Installing Dependencies for the Backend
3+
## Setting up the Backend
44

5-
### Installing Dependencies
5+
### Install Dependencies
66

77
1. **Python 3.7** - Follow instructions to install the latest version of python for your platform in the [python docs](https://docs.python.org/3/using/unix.html#getting-and-installing-the-latest-version-of-python)
88

@@ -18,11 +18,11 @@ pip install -r requirements.txt
1818

1919
- [Flask](http://flask.pocoo.org/) is a lightweight backend microservices framework. Flask is required to handle requests and responses.
2020

21-
- [SQLAlchemy](https://www.sqlalchemy.org/) is the Python SQL toolkit and ORM we'll use handle the lightweight sqlite database. You'll primarily work in app.py and can reference models.py.
21+
- [SQLAlchemy](https://www.sqlalchemy.org/) is the Python SQL toolkit and ORM we'll use to handle the lightweight SQL database. You'll primarily work in `app.py`and can reference `models.py`.
2222

23-
- [Flask-CORS](https://flask-cors.readthedocs.io/en/latest/#) is the extension we'll use to handle cross origin requests from our frontend server.
23+
- [Flask-CORS](https://flask-cors.readthedocs.io/en/latest/#) is the extension we'll use to handle cross-origin requests from our frontend server.
2424

25-
### Database Setup
25+
### Set up the Database
2626

2727
With Postgres running, create a `trivia` database:
2828

@@ -36,7 +36,7 @@ Populate the database using the `trivia.psql` file provided. From the `backend`
3636
psql trivia < trivia.psql
3737
```
3838

39-
### Running the server
39+
### Run the Server
4040

4141
From within the `./src` directory first ensure you are working using your created virtual environment.
4242

@@ -58,49 +58,43 @@ These are the files you'd want to edit in the backend:
5858
One note before you delve into your tasks: for each endpoint, you are expected to define the endpoint and response data. The frontend will be a plentiful resource because it is set up to expect certain endpoints and response data formats already. You should feel free to specify endpoints in your own way; if you do so, make sure to update the frontend or you will get some unexpected behavior.
5959

6060
1. Use Flask-CORS to enable cross-domain requests and set response headers.
61-
62-
2. Create an endpoint to handle GET requests for questions, including pagination (every 10 questions). This endpoint should return a list of questions, number of total questions, current category, categories.
63-
64-
3. Create an endpoint to handle GET requests for all available categories.
65-
66-
4. Create an endpoint to DELETE question using a question ID.
67-
68-
5. Create an endpoint to POST a new question, which will require the question and answer text, category, and difficulty score.
69-
70-
6. Create a POST endpoint to get questions based on category.
71-
72-
7. Create a POST endpoint to get questions based on a search term. It should return any questions for whom the search term is a substring of the question.
73-
74-
8. Create a POST endpoint to get questions to play the quiz. This endpoint should take category and previous question parameters and return a random questions within the given category, if provided, and that is not one of the previous questions.
75-
76-
9. Create error handlers for all expected errors including 400, 404, 422 and 500.
61+
2. Create an endpoint to handle `GET` requests for questions, including pagination (every 10 questions). This endpoint should return a list of questions, number of total questions, current category, categories.
62+
3. Create an endpoint to handle `GET` requests for all available categories.
63+
4. Create an endpoint to `DELETE` a question using a question `ID`.
64+
5. Create an endpoint to `POST` a new question, which will require the question and answer text, category, and difficulty score.
65+
6. Create a `POST` endpoint to get questions based on category.
66+
7. Create a `POST` endpoint to get questions based on a search term. It should return any questions for whom the search term is a substring of the question.
67+
8. Create a `POST` endpoint to get questions to play the quiz. This endpoint should take a category and previous question parameters and return a random questions within the given category, if provided, and that is not one of the previous questions.
68+
9. Create error handlers for all expected errors including 400, 404, 422, and 500.
7769

7870
## Documenting your Endpoints
7971

80-
You will need to provide detailed documentation of your API endpoints including the URL, request parameters and the response body. Use the example below as a reference.
72+
You will need to provide detailed documentation of your API endpoints including the URL, request parameters, and the response body. Use the example below as a reference.
8173

8274
### Documentation Example
8375

84-
GET `'/api/v1.0/categories'`
76+
`GET '/api/v1.0/categories'`
8577

8678
- Fetches a dictionary of categories in which the keys are the ids and the value is the corresponding string of the category
8779
- Request Arguments: None
88-
- Returns: An object with a single key, categories, that contains a object of id: category_string key:value pairs.
89-
90-
```bash
91-
{'1' : "Science",
92-
'2' : "Art",
93-
'3' : "Geography",
94-
'4' : "History",
95-
'5' : "Entertainment",
96-
'6' : "Sports"}
80+
- Returns: An object with a single key, `categories`, that contains an object of `id: category_string` key: value pairs.
81+
82+
```json
83+
{
84+
"1": "Science",
85+
"2": "Art",
86+
"3": "Geography",
87+
"4": "History",
88+
"5": "Entertainment",
89+
"6": "Sports"
90+
}
9791
```
9892

9993
## Testing
10094

10195
Write at least one test for the success and at least one error behavior of each endpoint using the unittest library.
10296

103-
To run the tests, run
97+
To deploy the tests, run
10498

10599
```bash
106100
dropdb trivia_test

frontend/README.md

Lines changed: 71 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Getting Setup
44

5-
> _tip_: this frontend is designed to work with [Flask-based Backend](../backend) so it will not load successfully if the backend is not working or not connect. We recommend that you **stand up the backend first**, test using Postman or curl, update the endpoints in the frontend, and then the frontend should integrate smoothly.
5+
> _tip_: this frontend is designed to work with [Flask-based Backend](../backend) so it will not load successfully if the backend is not working or not connected. We recommend that you **stand up the backend first**, test using Postman or curl, update the endpoints in the frontend, and then the frontend should integrate smoothly.
66
77
### Installing Dependencies
88

@@ -63,22 +63,24 @@ You can optionally update this game play to increase the number of questions or
6363

6464
> Only read the below to confirm your notes regarding the expected API endpoint behavior based on reading the frontend codebase.
6565
66-
**Here are the expected endpoints and behavior**:
66+
### Expected endpoints and behaviors
6767

6868
`GET '/categories'`
6969

7070
- Fetches a dictionary of categories in which the keys are the ids and the value is the corresponding string of the category
7171
- Request Arguments: None
7272
- Returns: An object with a single key, categories, that contains an object of id: category_string key:value pairs.
7373

74-
```bash
74+
```json
7575
{
76-
'categories': { '1' : "Science",
77-
'2' : "Art",
78-
'3' : "Geography",
79-
'4' : "History",
80-
'5' : "Entertainment",
81-
'6' : "Sports" }
76+
"categories": {
77+
"1": "Science",
78+
"2": "Art",
79+
"3": "Geography",
80+
"4": "History",
81+
"5": "Entertainment",
82+
"6": "Sports"
83+
}
8284
}
8385
```
8486

@@ -90,25 +92,27 @@ You can optionally update this game play to increase the number of questions or
9092
- Request Arguments: `page` - integer
9193
- Returns: An object with 10 paginated questions, total questions, object including all categories, and current category string
9294

93-
```bash
95+
```json
9496
{
95-
'questions': [
96-
{
97-
'id': 1,
98-
'question': 'This is a question',
99-
'answer': 'This is an answer',
100-
'difficulty': 5,
101-
'category': 2
102-
},
103-
],
104-
'totalQuestions': 100,
105-
'categories': { '1' : "Science",
106-
'2' : "Art",
107-
'3' : "Geography",
108-
'4' : "History",
109-
'5' : "Entertainment",
110-
'6' : "Sports" },
111-
'currentCategory': 'History'
97+
"questions": [
98+
{
99+
"id": 1,
100+
"question": "This is a question",
101+
"answer": "This is an answer",
102+
"difficulty": 5,
103+
"category": 2
104+
}
105+
],
106+
"totalQuestions": 100,
107+
"categories": {
108+
"1": "Science",
109+
"2": "Art",
110+
"3": "Geography",
111+
"4": "History",
112+
"5": "Entertainment",
113+
"6": "Sports"
114+
},
115+
"currentCategory": "History"
112116
}
113117
```
114118

@@ -120,19 +124,19 @@ You can optionally update this game play to increase the number of questions or
120124
- Request Arguments: `id` - integer
121125
- Returns: An object with questions for the specified category, total questions, and current category string
122126

123-
```bash
127+
```json
124128
{
125-
'questions': [
126-
{
127-
'id': 1,
128-
'question': 'This is a question',
129-
'answer': 'This is an answer',
130-
'difficulty': 5,
131-
'category': 4
132-
},
133-
],
134-
'totalQuestions': 100,
135-
'currentCategory': 'History'
129+
"questions": [
130+
{
131+
"id": 1,
132+
"question": "This is a question",
133+
"answer": "This is an answer",
134+
"difficulty": 5,
135+
"category": 4
136+
}
137+
],
138+
"totalQuestions": 100,
139+
"currentCategory": "History"
136140
}
137141
```
138142

@@ -151,7 +155,7 @@ You can optionally update this game play to increase the number of questions or
151155
- Sends a post request in order to get the next question
152156
- Request Body:
153157

154-
```bash
158+
```json
155159
{
156160
'previous_questions': [1, 4, 20, 15]
157161
quiz_category': 'current category'
@@ -160,15 +164,15 @@ You can optionally update this game play to increase the number of questions or
160164

161165
- Returns: a single new question object
162166

163-
```bash
167+
```json
164168
{
165-
'question': {
166-
'id': 1,
167-
'question': 'This is a question',
168-
'answer': 'This is an answer',
169-
'difficulty': 5,
170-
'category': 4
171-
}
169+
"question": {
170+
"id": 1,
171+
"question": "This is a question",
172+
"answer": "This is an answer",
173+
"difficulty": 5,
174+
"category": 4
175+
}
172176
}
173177
```
174178

@@ -179,12 +183,12 @@ You can optionally update this game play to increase the number of questions or
179183
- Sends a post request in order to add a new question
180184
- Request Body:
181185

182-
```bash
186+
```json
183187
{
184-
'question': 'Heres a new question string',
185-
'answer': 'Heres a new answer string',
186-
'difficulty': 1,
187-
'category': 3,
188+
"question": "Heres a new question string",
189+
"answer": "Heres a new answer string",
190+
"difficulty": 1,
191+
"category": 3
188192
}
189193
```
190194

@@ -197,27 +201,26 @@ You can optionally update this game play to increase the number of questions or
197201
- Sends a post request in order to search for a specific question by search term
198202
- Request Body:
199203

200-
```bash
204+
```json
201205
{
202-
'searchTerm': 'this is the term the user is looking for'
206+
"searchTerm": "this is the term the user is looking for"
203207
}
204-
205208
```
206209

207210
- Returns: any array of questions, a number of totalQuestions that met the search term and the current category string
208211

209-
```bash
212+
```json
210213
{
211-
'questions': [
212-
{
213-
'id': 1,
214-
'question': 'This is a question',
215-
'answer': 'This is an answer',
216-
'difficulty': 5,
217-
'category': 5
218-
},
219-
],
220-
'totalQuestions': 100,
221-
'currentCategory': 'Entertainment'
214+
"questions": [
215+
{
216+
"id": 1,
217+
"question": "This is a question",
218+
"answer": "This is an answer",
219+
"difficulty": 5,
220+
"category": 5
221+
}
222+
],
223+
"totalQuestions": 100,
224+
"currentCategory": "Entertainment"
222225
}
223226
```

0 commit comments

Comments
 (0)