You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Udacity is invested in creating bonding experiences for its employees and students. A bunch of team members got the idea to hold trivia on a regular basis and created a webpage to manage the trivia app and play the game, but their API experience is limited and still needs to be built out.
6
6
@@ -16,32 +16,34 @@ Completing this trivia app will give you the ability to structure plan, implemen
16
16
17
17
## Starting and Submitting the Project
18
18
19
-
[Fork](https://help.github.com/en/articles/fork-a-repo) the project repository and [Clone](https://help.github.com/en/articles/cloning-a-repository) your forked repository to your local machine or to the classrooom workspace. Work on the project and make sure to push all your changes to the remote repository before submitting the project.
19
+
[Fork](https://help.github.com/en/articles/fork-a-repo) the project repository and [clone](https://help.github.com/en/articles/cloning-a-repository) your forked repository to your machine. Work on the project locally and make sure to push all your changes to the remote repository before submitting the link to your repository in the Classroom.
20
20
21
21
## About the Stack
22
22
23
23
We started the full stack application for you. It is designed with some key functional areas:
24
24
25
25
### Backend
26
26
27
-
The [./backend](./backend/README.md) directory contains a partially completed Flask and SQLAlchemy server. You will work primarily in `__init__.py` to define your endpoints and can reference models.py for DB and SQLAlchemy setup. These are the files you'd want to edit in the backend:
27
+
The [backend](./backend/README.md) directory contains a partially completed Flask and SQLAlchemy server. You will work primarily in `__init__.py` to define your endpoints and can reference models.py for DB and SQLAlchemy setup. These are the files you'd want to edit in the backend:
28
28
29
-
1.`./backend/flaskr/__init__.py`
30
-
2.`./backend/test_flaskr.py`
29
+
1.`backend/flaskr/__init__.py`
30
+
2.`backend/test_flaskr.py`
31
+
32
+
> View the [Backend README](./backend/README.md) for more details.
31
33
32
34
### Frontend
33
35
34
-
The [./frontend](./frontend/README.md) directory contains a complete React frontend to consume the data from the Flask server. If you have prior experience building a frontend application, you should feel free to edit the endpoints as you see fit for the backend you design. If you do not have prior experience building a frontend application, you should read through the frontend code before starting and make notes regarding:
36
+
The [frontend](./frontend/README.md) directory contains a complete React frontend to consume the data from the Flask server. If you have prior experience building a frontend application, you should feel free to edit the endpoints as you see fit for the backend you design. If you do not have prior experience building a frontend application, you should read through the frontend code before starting and make notes regarding:
35
37
36
38
1. What are the end points and HTTP methods the frontend is expecting to consume?
37
39
2. How are the requests from the frontend formatted? Are they expecting certain parameters or payloads?
38
40
39
41
Pay special attention to what data the frontend is expecting from each API response to help guide how you format your API. The places where you may change the frontend behavior, and where you should be looking for the above information, are marked with `TODO`. These are the files you'd want to edit in the frontend:
40
42
41
-
1.`./frontend/src/components/QuestionView.js`
42
-
2.`./frontend/src/components/FormView.js`
43
-
3.`/frontend/src/components/QuizView.js`
43
+
1.`frontend/src/components/QuestionView.js`
44
+
2.`frontend/src/components/FormView.js`
45
+
3.`frontend/src/components/QuizView.js`
44
46
45
47
By making notes ahead of time, you will practice the core skill of being able to read and understand code and will have a simple plan to follow to build out the endpoints of your backend API.
46
48
47
-
> View the [README within ./frontend for more details.](./frontend/README.md)
49
+
> View the [Frontend README](./frontend/README.md) for more details.
Copy file name to clipboardExpand all lines: backend/README.md
+25-18Lines changed: 25 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,20 @@
1
-
# Backend - Full Stack Trivia API
1
+
# Backend - Trivia API
2
2
3
3
## Installing Dependencies for the Backend
4
4
5
+
### Installing Dependencies
6
+
5
7
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)
6
8
7
-
2.**Virtual Enviornment** - We recommend working within a virtual environment whenever using Python for projects. This keeps your dependencies for each project separate and organaized. Instructions for setting up a virual enviornment for your platform can be found in the [python docs](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/)
9
+
2.**Virtual Environment** - We recommend working within a virtual environment whenever using Python for projects. This keeps your dependencies for each project separate and organized. Instructions for setting up a virual environment for your platform can be found in the [python docs](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/)
8
10
9
-
3.**PIP Dependencies** - Once you have your virtual environment setup and running, install all of the required packages we selected within the `requirements.txt` filed by navigating to the `/backend` directory and running:
11
+
3.**PIP Dependencies** - Once your virtual environment is setup and running, install the required dependencies by navigating to the `/backend` directory and running:
10
12
11
13
```bash
12
14
pip install -r requirements.txt
13
15
```
14
16
15
-
4.**Key Dependencies**
17
+
#### Key Pip Dependencies
16
18
17
19
-[Flask](http://flask.pocoo.org/) is a lightweight backend microservices framework. Flask is required to handle requests and responses.
With Postgres running, restore a database using the trivia.psql file provided. From the backend folder in terminal run:
27
+
With Postgres running, create a `trivia` database:
28
+
29
+
```bash
30
+
createbd trivia
31
+
```
32
+
33
+
Populate the database using the `trivia.psql` file provided. From the `backend` folder in terminal run:
26
34
27
35
```bash
28
36
psql trivia < trivia.psql
@@ -40,12 +48,12 @@ flask run --reload
40
48
41
49
The `--reload` flag will detect file changes and restart the server automatically.
42
50
43
-
## ToDo Tasks
51
+
## To Do Tasks
44
52
45
53
These are the files you'd want to edit in the backend:
46
54
47
-
1.`./backend/flaskr/__init__.py`
48
-
2.`./backend/test_flaskr.py`
55
+
1.`backend/flaskr/__init__.py`
56
+
2.`backend/test_flaskr.py`
49
57
50
58
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.
51
59
@@ -67,32 +75,31 @@ One note before you delve into your tasks: for each endpoint, you are expected t
67
75
68
76
9. Create error handlers for all expected errors including 400, 404, 422 and 500.
69
77
70
-
## Review Comment to the Students
78
+
## Documenting your Endpoints
71
79
72
-
This README is missing documentation of your endpoints. Below is an example for your endpoint to get all categories. Please use it as a reference for creating your documentation and resubmit your code.
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.
73
81
74
-
```bash
75
-
Endpoints
76
-
GET '/api/v1.0/categories'
77
-
GET ...
78
-
POST ...
79
-
DELETE ...
82
+
### Documentation Example
83
+
84
+
GET `'/api/v1.0/categories'`
80
85
81
-
GET '/api/v1.0/categories'
82
86
- Fetches a dictionary of categories in which the keys are the ids and the value is the corresponding string of the category
83
87
- Request Arguments: None
84
88
- Returns: An object with a single key, categories, that contains a object of id: category_string key:value pairs.
89
+
90
+
```bash
85
91
{'1':"Science",
86
92
'2':"Art",
87
93
'3':"Geography",
88
94
'4':"History",
89
95
'5':"Entertainment",
90
96
'6':"Sports"}
91
-
92
97
```
93
98
94
99
## Testing
95
100
101
+
Write at least one test for the success and at least one error behavior of each endpoint using the unittest library.
0 commit comments