Developing RESTful APIs with Python and Flask

PHOTO EMBED

Thu Mar 03 2022 07:17:07 GMT+0000 (Coordinated Universal Time)

Saved by @morristech #python

import datetime as dt

from marshmallow import Schema, fields


class Transaction():
  def __init__(self, description, amount, type):
    self.description = description
    self.amount = amount
    self.created_at = dt.datetime.now()
    self.type = type

  def __repr__(self):
    return '<Transaction(name={self.description!r})>'.format(self=self)


class TransactionSchema(Schema):
  description = fields.Str()
  amount = fields.Number()
  created_at = fields.Date()
  type = fields.Str()
content_copyCOPY

https://auth0.com/blog/developing-restful-apis-with-python-and-flask/