Skip to content

mid and final project for REST-API course - #1

Open
davidspythonjourney wants to merge 1 commit into
mainfrom
PR_rest
Open

mid and final project for REST-API course#1
davidspythonjourney wants to merge 1 commit into
mainfrom
PR_rest

Conversation

@davidspythonjourney

Copy link
Copy Markdown
Owner

No description provided.

Comment thread final_project.py
app = Flask(__name__)
#change for pr
JSON_NUM = 0
tasks = {}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is JSON_NUM capital and tasks small? be consistent (no need to re-submit)

Comment thread final_project.py
def completeTask(task_id):
global tasks
if task_id in tasks:
tasks[task_id]["message"] = "Task marked as completed"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont quite understand the stucture of a task in your code. it has a title AND a message field? or the message is only for the REST response?

Comment thread final_project.py
if not data or "title" not in data or "description" not in data:
return jsonify({"error": "Bad Request, data must include 'title' and 'description' "}), 400
JSON_NUM += 1
new_task = {str(JSON_NUM): {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

Comment thread final_project.py
def updateTask(task_id):
global tasks
data = request.get_json()
if not data or "title" not in data or "description" not in data:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplication. i suggest an function for the "if"

Comment thread final_project.py
global tasks
data = request.get_json()
if not data or "title" not in data or "description" not in data:
return jsonify({"error": "Bad Request, data must include 'name' and 'age'"}), 400

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checking name and age? this message is from another project :)

Comment thread final_project.py
global tasks
if task_id in tasks:
if tasks[task_id]["completed"] is True:
del tasks[task_id]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice idea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants