Forums

Flask Website Error, apparently related to the wsgi_app?

My code is this:

# A very simple Flask Hello World app for you to get started with...
from flask import Flask, request
import requests


app = Flask(__name__)

@app.route('/', methods = ["GET", "POST"])
def hello_world():

    if request.method == "POST":
        countries = request.form["Enter Countries"]
        return '''
                <html>
                    <body>
                        <p>The countries you asked us to graph are {result}</p>
                        <p><a href="/">Click here to calculate again</a>
                    </body>
                </html>

        '''.format(result = countries)
    else:
        return
        '''
            <html>
                <body>
                    <p>Enter your numbers:</p>
                    <form method="post" action=".">
                        <p><input name="Enter Countries" /></p>
                        <p><input type="submit" value="Graph Countries" /></p>
                    </form>
                </body>
            </html>
    '''

The error I am receiving is this: 2020-06-27 19:54:00,854: Exception on / [GET] Traceback (most recent call last): File "/usr/lib/python3.8/site-packages/flask/app.py", line 2446, in wsgi_app response = self.full_dispatch_request() File "/usr/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request return self.finalize_request(rv) File "/usr/lib/python3.8/site-packages/flask/app.py", line 1967, in finalize_request response = self.make_response(rv) File "/usr/lib/python3.8/site-packages/flask/app.py", line 2096, in make_response raise TypeError( TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement. 2020-06-27 19:54:23,055: Exception on / [GET] Traceback (most recent call last): File "/usr/lib/python3.8/site-packages/flask/app.py", line 2446, in wsgi_app response = self.full_dispatch_request()

Please forgive me for being clueless, I am new to python anywhere. That being said, please help me find what is causing this error.

That code would not produce that error. Have you reloaded your web app since you last made changes to your web app code?

did you solve this problem? I have the same one

How does your view for "/" look like?