Heres exactly what the over code has been doing:
Outlines step one 9 transfer certain Flask modules to manufacture the others API solutions, in addition to uploading this new db such as for instance regarding the config.py module. On top of that, it imports new SQLAlchemy Person and you will Marshmallow PersonSchema groups to view the individual database table and you will serialize the results.
Range eleven starts the phrase see_all() you to reacts to your Other people API Hyperlink endpoint Score /api/individuals and you will yields all the records regarding the people database dining table arranged within the ascending order by past label.
Contours 19 twenty-two give SQLAlchemy so you can ask anyone database table for everybody this new records, kinds her or him inside ascending order (the brand new standard sorting purchase), and you may come back a list of Person Python objects due to the fact variable individuals .
Line 24 is the perfect place the fresh Marshmallow PersonSchema group meaning becomes valuable. You will be making an illustration of the fresh new PersonSchema , passing they the brand new factor of a lot=True . Which informs PersonSchema you may anticipate an enthusiastic interable in order to serialize, that’s what the some body varying are.
Line twenty-five spends brand new PersonSchema like variable ( person_outline ), calling their treat() method toward some body list. As a result, an object with a data attribute, an object with an everyone number which are often transformed into JSON. That is came back and you will converted because of the Connexion in order to JSON since the reaction to others API name.
Note: People checklist changeable written on the internet twenty four over is alsot be came back truly since Connexion acquiredt can move new timestamp occupation towards the JSON. Read More
Neueste Kommentare