Created
June 2, 2019 21:10
-
-
Save mysteriousHerb/c0ed79f411b2a9133920966c1b4560ff to your computer and use it in GitHub Desktop.
backend/test_backend.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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