ADD file via upload
This commit is contained in:
parent
4fc06b5d6e
commit
650d8c3361
|
@ -0,0 +1,29 @@
|
|||
# backend/app.py
|
||||
from flask import Flask, request, jsonify
|
||||
|
||||
from flask_cors import *
|
||||
|
||||
app = Flask(__name__)
|
||||
CORS(app, supports_credentials=True)
|
||||
|
||||
todos = []
|
||||
|
||||
@app.route("/")
|
||||
def hello():
|
||||
return "Hello, World!"
|
||||
@app.route("/todos", methods=["GET"])
|
||||
def get_todos():
|
||||
return jsonify(todos)
|
||||
@app.route("/todos", methods=["POST"])
|
||||
def add_todo():
|
||||
todo = request.json
|
||||
todos.append(todo)
|
||||
return jsonify(todo), 201
|
||||
@app.route("/todos/<int:index>", methods=["DELETE"])
|
||||
def delete_todo(index):
|
||||
if index < len(todos):
|
||||
deleted_todo = todos.pop(index)
|
||||
return jsonify(deleted_todo)
|
||||
return "", 404
|
||||
if __name__ == "__main__":
|
||||
app.run(debug=True)
|
Loading…
Reference in New Issue