FROM.txt 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. See:
  2. http://flask-restful.readthedocs.io/en/0.3.5/quickstart.html
  3. Using httpauth:
  4. https://blog.miguelgrinberg.com/post/restful-authentication-with-flask
  5. Using SQLAlchemy and Flask:
  6. http://flask-sqlalchemy.pocoo.org/2.3/quickstart/
  7. # Because of a bug in oursql, I need to download and install manually...
  8. wget https://launchpad.net/oursql/py3k/py3k-0.9.4/+download/oursql-0.9.4.zip
  9. pip install oursql-0.9.4.zip
  10. sql_todo init:
  11. python
  12. import sql_todo
  13. sql_todo.db.create_all()
  14. Testing sql_todo:
  15. curl 127.0.0.1:11022/todos
  16. curl 127.0.0.1:11022/todos/1
  17. curl 127.0.0.1:11022/todos/test -d "task=Further testing of delete path" -X PUT -v
  18. curl 127.0.0.1:11022/todos/3 -X DELETE -v
  19. # and now!
  20. curl 127.0.0.1:11022/todos -d "name=fish" -d "task=Invoke fish" -X POST -v
  21. # Needs json header.
  22. curl -H "Content-Type: application/json" 127.0.0.1:11022/todos -d '{"name":"fish2", "task":"Inflate fish"}' -X POST -v
  23. Creating models.py:
  24. flask-sqlacodegen --outfile models.py --flask mysql+oursql://root:###ROOTPASSWORD##@localhost:3306/ibr