A simple starter flask app used for teaching - A basic feedback summarizer using OpenAI
This repo is a starter flask app for teaching purposes.
This particular variant was made to demonstrate how to use flask with the OpenAI.
For a more basic introduction, see Starter Flask App.
git clone <URL>

If you don’t already, install python and pip. If you’re not sure if you have python installed, try running it locally in your command line with python --version.

Navigate to the directory where you cloned this repo.
Run the following command to install the required packages:
pip install -r requirements.txt
Get an (OpenAI API Key)[https://openai.com/index/openai-api/] and set it to the environment variable OPENAI_API_KEY.
OPENAI_API_KEY="sk-..."
Run the following command to start the flask app defined in the app.py file:
flask run

Open your browser and navigate to http://127.0.0.1:5000 to see the app running locally.
This app is a minimal server/client web application that template rendering, form submission, a database, and OpenAI to collect and summarize feedback from students.
It has two entry points:
Below is a sequence diagram explaining how it works with two students feedback, Alice and Bobs.
sequenceDiagram
autonumber
participant Alice
participant Bob
participant MrP as Mr. P
participant Server
participant Database
participant OpenAI as OpenAI LLM
Alice->>Server: GET /
Server->>Alice: index.html
Alice->>Server: POST "Alice's Feedback" to /feedback
Server->>Database: INSERT "Alice's Feedback" ...
Server->>Alice: thanks.html
Bob->>Server: GET /
Server->>Bob: index.html
Bob->>Server: POST "Bob's Feedback" to /feedback
Server->>Database: INSERT "Bob's Feedback" ...
Server->>Bob: thanks.html
MrP->>Server: Get /summarize_feedback
Database->>Server: SELECT feedback ...
Server->>OpenAI: "Summarize feedback ..."
OpenAI->>Server: "The summary is.."
Server->>MrP: summary.html, "The summary is..."
GET request to the / URL (the root).index.html, a page to fill out her feedback.POST request with her feedback to the /feedback URL.thanks.html page to AliceGET request to the / URL (the root).index.html, a page to fill out his feedback.POST request with his feedback to the /feedback URL.thanks.html page to Bob/summarize_feedback URL