Skip to content

pyfq/aiodemo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aiodemo

a todo demo based on aiohttp、aiomysql、sqlalchamy

Run:

  1. init database structure by todo.sql
  2. update db config to yours in config.py
  3. pip install -r requirements.txt
  4. python server.py

Example:

>>> import requests  
>>> resp = requests.post('http://localhost:8080/todos', json={'content': 'fisrt todo'})  
>>> resp.status_code  
200  
>>> resp = requests.get('http://localhost:8080/todos')  
>>> resp.json()  
[{u'content': u'fisrt todo', u'finished': u'no', u'id': 1}]  
>>> resp = requests.patch('http://localhost:8080/todos/1', json={'finished': 'yes'})  
>>> resp.status_code  
204  
>>> resp = requests.get('http://localhost:8080/todos/1')  
>>> resp.json()  
{u'content': u'fisrt todo', u'finished': u'yes', u'id': 1}  
>>> resp = requests.delete('http://localhost:8080/todos/1')  
>>> resp.status_code  
204  
>>> resp = requests.get('http://localhost:8080/todos/1')  
>>> resp.json()  
{u'error': u'Todo not found'}  

About

A todo demo based on aiohttp、aiomysql、sqlalchamy

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages