1. Jérôme Pigeot
  2. Resttest

Wiki

Clone wiki

Resttest / Home

RestTest

This mini flask app intents to render SQLAlchemy models into xml/json resources.

Requirements

Usage

option 1:

  • Run a python shell in the "root" folder and type the following commands:
from resttest.database import init_db, db_session
from resttest.models import Theme, Event

# database creation
init_db()

# let's create objects
theme = Theme(u'Sport')
event = Event(u'Basket-ball game', theme)

# saving in the database
db_session.add_all([theme, event])
db_session.commit()

option 2

  • Run the database creation command:
# -b is used for creating some objects in the database
$ python manager.py create_db -b

Testing

  • Run a python server:
$ python manage.py runserver
  • Now run a browser with the following addresses:

http://localhost:5000/api/themes/
http://localhost:5000/api/themes/?format=xml

http://localhost:5000/api/events/
http://localhost:5000/api/events/?format=xml

Updated