O'Reilly logo

Instant Flask Web Development by Ron DuPlain

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a new record (Intermediate)

Here we provide a web form to create a new appointment as shown in the following screenshot:

Creating a new record (Intermediate)

Getting ready

We will continue to work from the app.py file from sched and the templates directory.

How to do it...

  1. We provide a view function to do both GET and POST handling for the form. Here, we pull together db.session from the database section and AppointmentForm from the forms section. In app.py:
    from flask import abort, jsonify, redirect, render_template from flask import request, url_for from sched.forms import AppointmentForm from sched.models import Appointment # ... skipping ahead. Keep previous code from app.py ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required