Now in order to use our new poembot.py functionality in our web application we need to import it into our application.
At the top of app.py (after the from Flask
line) add this line:
import poembot
Now your module is ready to use within your web application.
# app.py
from flask import Flask, render_template, redirect, url_for, jsonify
import poembot
app = Flask(__name__)
@app.route('/')
def hello():
return "Hello world!"
@app.route('/poem')
def poem():
return "A great poem will be here!"
if __name__ == '__main__':
app.run(debug=True)