- Import some core definitions from the flask package. The Flask class defines the overall application. The request object holds the current web request:
from flask import Flask, request, jsonify, abort from http import HTTPStatus
The jsonify() function will return a JSON-format object from a Flask view function. The abort() function returns an HTTP error status and ends processing of the request.
- Import the underlying classes, Card and Deck. Ideally, these are imported from a separate module. It should be possible to test all of the features outside the web services environment:
from ch12_r01 import Card, Deck
In order to properly shuffle, we'll also need the random module:
import random
- Create the Flask object. ...