Creating the server

This parallels the server shown in the Parsing a JSON request recipe. There are some important modifications:

  1. Create the local self-signed certificate or purchase a certificate from a certificate authority. For this recipe, we'll assume the two filenames are ssl.cert and ssl.key.
  2. Import the modules required to build a server. Also import the User class definition:

        from flask import Flask, jsonify, request, abort, url_for 
        from ch12_r07_user import User 
        from http import HTTPStatus 
  1. Include the @authorization_required decorator definition.
  2. Define a route with no authentication. This will be used to create new users. A similar view function was defined in the Parsing a JSON request recipe. This version requires a password ...

Get Modern Python Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.