Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codespace literate xylophone wqpp6x7wvjqf5996 #104

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
flask = "*"

[dev-packages]

[requires]
python_version = "3.10"
python_full_version = "3.10.12"
136 changes: 136 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions src/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from flask import Flask, jsonify, request
app = Flask(__name__)

todos = [
{ "label": "Comer", "done": False },
{ "label": "Ducharse", "done": False }
]

@app.route('/todos', methods=['GET'])
def hello_world():
json_text = jsonify(todos)
return json_text

@app.route('/todos', methods=['POST'])

def add_new_todo():
request_body = request.json
print("Peticion entrante ", request_body)
todos.append(request_body)
return jsonify(todos)

@app.route('/todos/<int:position>', methods=['DELETE'])

def delete_todo(position):
print("Esta es la posicion para borrar", position)
todos.pop(position)
return jsonify(todos)

if __name__ == '__main__':
app.run(host='0.0.0.0', port=3245, debug=True)