Skip to content

Instantly share code, notes, and snippets.

@mysteriousHerb
Created June 2, 2019 21:10
Show Gist options
  • Save mysteriousHerb/c0ed79f411b2a9133920966c1b4560ff to your computer and use it in GitHub Desktop.
Save mysteriousHerb/c0ed79f411b2a9133920966c1b4560ff to your computer and use it in GitHub Desktop.
backend/test_backend.py
import requests
# using requests library to test backend without using frontend
def query():
response = requests.get('http://localhost:5000/todo_db')
print(response.json())
query()
# add new item
data = {'content':'add a new todo ', 'done':False}
response = requests.post('http://localhost:5000/todo_db', json= data)
query()
# update the old item
data = {'content':'change a old todo ', 'done':True, 'id':1}
response = requests.post('http://localhost:5000/todo_db', json= data)
query()
# remove item
data = {'delete': True, 'id':2}
response = requests.post('http://localhost:5000/todo_db', json= data)
query()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment