Forums

First time deploying a Flask application

Hi everyone,

I'm in the process of trying to deploy my first Flask web app, but I keep running into this ImportError

Here's what the _init_.py file looks like:

import os

import openai

from flask import Flask, render_template, request, redirect, url_for, session

def create_app(test_config = None):
    app = Flask(__name__, instance_relative_config = True)

    app.config.from_mapping(SECRET_KEY = 'dev')

    @app.route('/', methods=('GET', 'POST'))
    def index():
        if request.method == 'POST':

            # code omitted

            return redirect(url_for('summary'))

        return render_template('index.html')

    @app.route('/summary', methods=('GET', 'POST'))
    def summary():

        if request.method == 'POST':
            #code omitted

        return render_template('summary.html', response=response.get('choices')[0].get('text').strip(), link=session.get('text'))

    return app

This is what the directory looks like. I attempted to follow the official steps here but I think I'm missing something potentially.

Any advice would be greatly appreciated.

Update: Managed to get this to work.

Great! Thanks for letting us know.