Skip to content

Commit cf8d368

Browse files
committed
Clean up code and instructions
1 parent 160f627 commit cf8d368

21 files changed

+8758
-9333
lines changed

README.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# API Development and Documentation Final Project
1+
# Full Stack API Final Project
22

3-
## Full Stack Trivia
3+
## Trivia App
44

55
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.
66

@@ -16,32 +16,34 @@ Completing this trivia app will give you the ability to structure plan, implemen
1616

1717
## Starting and Submitting the Project
1818

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.
2020

2121
## About the Stack
2222

2323
We started the full stack application for you. It is designed with some key functional areas:
2424

2525
### Backend
2626

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:
2828

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.
3133
3234
### Frontend
3335

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:
3537

3638
1. What are the end points and HTTP methods the frontend is expecting to consume?
3739
2. How are the requests from the frontend formatted? Are they expecting certain parameters or payloads?
3840

3941
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:
4042

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`
4446

4547
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.
4648

47-
> View the [README within ./frontend for more details.](./frontend/README.md)
49+
> View the [Frontend README](./frontend/README.md) for more details.

backend/README.md

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
# Backend - Full Stack Trivia API
1+
# Backend - Trivia API
22

33
## Installing Dependencies for the Backend
44

5+
### Installing Dependencies
6+
57
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)
68

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/)
810

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:
1012

1113
```bash
1214
pip install -r requirements.txt
1315
```
1416

15-
4. **Key Dependencies**
17+
#### Key Pip Dependencies
1618

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

@@ -22,7 +24,13 @@ pip install -r requirements.txt
2224

2325
### Database Setup
2426

25-
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:
2634

2735
```bash
2836
psql trivia < trivia.psql
@@ -40,12 +48,12 @@ flask run --reload
4048

4149
The `--reload` flag will detect file changes and restart the server automatically.
4250

43-
## ToDo Tasks
51+
## To Do Tasks
4452

4553
These are the files you'd want to edit in the backend:
4654

47-
1. `./backend/flaskr/__init__.py`
48-
2. `./backend/test_flaskr.py`
55+
1. `backend/flaskr/__init__.py`
56+
2. `backend/test_flaskr.py`
4957

5058
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.
5159

@@ -67,32 +75,31 @@ One note before you delve into your tasks: for each endpoint, you are expected t
6775

6876
9. Create error handlers for all expected errors including 400, 404, 422 and 500.
6977

70-
## Review Comment to the Students
78+
## Documenting your Endpoints
7179

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.
7381

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'`
8085

81-
GET '/api/v1.0/categories'
8286
- Fetches a dictionary of categories in which the keys are the ids and the value is the corresponding string of the category
8387
- Request Arguments: None
8488
- Returns: An object with a single key, categories, that contains a object of id: category_string key:value pairs.
89+
90+
```bash
8591
{'1' : "Science",
8692
'2' : "Art",
8793
'3' : "Geography",
8894
'4' : "History",
8995
'5' : "Entertainment",
9096
'6' : "Sports"}
91-
9297
```
9398

9499
## Testing
95100

101+
Write at least one test for the success and at least one error behavior of each endpoint using the unittest library.
102+
96103
To run the tests, run
97104

98105
```bash

backend/flaskr/__init__.py

Lines changed: 60 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -12,93 +12,92 @@ def create_app(test_config=None):
1212
# create and configure the app
1313
app = Flask(__name__)
1414
setup_db(app)
15-
16-
'''
15+
16+
"""
1717
@TODO: Set up CORS. Allow '*' for origins. Delete the sample route after completing the TODOs
18-
'''
18+
"""
1919

20-
'''
20+
"""
2121
@TODO: Use the after_request decorator to set Access-Control-Allow
22-
'''
22+
"""
2323

24-
'''
25-
@TODO:
26-
Create an endpoint to handle GET requests
24+
"""
25+
@TODO:
26+
Create an endpoint to handle GET requests
2727
for all available categories.
28-
'''
28+
"""
2929

3030

31-
'''
32-
@TODO:
33-
Create an endpoint to handle GET requests for questions,
34-
including pagination (every 10 questions).
35-
This endpoint should return a list of questions,
36-
number of total questions, current category, categories.
31+
"""
32+
@TODO:
33+
Create an endpoint to handle GET requests for questions,
34+
including pagination (every 10 questions).
35+
This endpoint should return a list of questions,
36+
number of total questions, current category, categories.
3737
3838
TEST: At this point, when you start the application
3939
you should see questions and categories generated,
4040
ten questions per page and pagination at the bottom of the screen for three pages.
41-
Clicking on the page numbers should update the questions.
42-
'''
41+
Clicking on the page numbers should update the questions.
42+
"""
4343

44-
'''
45-
@TODO:
46-
Create an endpoint to DELETE question using a question ID.
44+
"""
45+
@TODO:
46+
Create an endpoint to DELETE question using a question ID.
4747
4848
TEST: When you click the trash icon next to a question, the question will be removed.
49-
This removal will persist in the database and when you refresh the page.
50-
'''
49+
This removal will persist in the database and when you refresh the page.
50+
"""
5151

52-
'''
53-
@TODO:
54-
Create an endpoint to POST a new question,
55-
which will require the question and answer text,
52+
"""
53+
@TODO:
54+
Create an endpoint to POST a new question,
55+
which will require the question and answer text,
5656
category, and difficulty score.
5757
58-
TEST: When you submit a question on the "Add" tab,
58+
TEST: When you submit a question on the "Add" tab,
5959
the form will clear and the question will appear at the end of the last page
60-
of the questions list in the "List" tab.
61-
'''
60+
of the questions list in the "List" tab.
61+
"""
6262

63-
'''
64-
@TODO:
65-
Create a POST endpoint to get questions based on a search term.
66-
It should return any questions for whom the search term
67-
is a substring of the question.
63+
"""
64+
@TODO:
65+
Create a POST endpoint to get questions based on a search term.
66+
It should return any questions for whom the search term
67+
is a substring of the question.
6868
69-
TEST: Search by any phrase. The questions list will update to include
70-
only question that include that string within their question.
71-
Try using the word "title" to start.
72-
'''
69+
TEST: Search by any phrase. The questions list will update to include
70+
only question that include that string within their question.
71+
Try using the word "title" to start.
72+
"""
7373

74-
'''
75-
@TODO:
76-
Create a GET endpoint to get questions based on category.
74+
"""
75+
@TODO:
76+
Create a GET endpoint to get questions based on category.
7777
78-
TEST: In the "List" tab / main screen, clicking on one of the
79-
categories in the left column will cause only questions of that
80-
category to be shown.
81-
'''
78+
TEST: In the "List" tab / main screen, clicking on one of the
79+
categories in the left column will cause only questions of that
80+
category to be shown.
81+
"""
8282

8383

84-
'''
85-
@TODO:
86-
Create a POST endpoint to get questions to play the quiz.
87-
This endpoint should take category and previous question parameters
88-
and return a random questions within the given category,
89-
if provided, and that is not one of the previous questions.
84+
"""
85+
@TODO:
86+
Create a POST endpoint to get questions to play the quiz.
87+
This endpoint should take category and previous question parameters
88+
and return a random questions within the given category,
89+
if provided, and that is not one of the previous questions.
9090
9191
TEST: In the "Play" tab, after a user selects "All" or a category,
9292
one question at a time is displayed, the user is allowed to answer
93-
and shown whether they were correct or not.
94-
'''
95-
96-
'''
97-
@TODO:
98-
Create error handlers for all expected errors
99-
including 404 and 422.
100-
'''
101-
93+
and shown whether they were correct or not.
94+
"""
95+
96+
"""
97+
@TODO:
98+
Create error handlers for all expected errors
99+
including 404 and 422.
100+
"""
101+
102102
return app
103103

104-

0 commit comments

Comments
 (0)