简体   繁体   中英

Internal Server error. Flask

I was running this script only a while back and suddenly it seems to give me an error.

@app.route('/')
def hello():
    return '''                    
                <form method="POST" action="/people">
                    <font size = "4">I am looking for?</font><br>
                    <font size = 2>Please enter atleast two words. </font><br><br>
                    <input name="search" type="text" width=1000px>
                    <br>
                    <input type="submit" value="People Search"/>
                    <br>
                </form>

                <form method="POST" action="/science">
                    <input name="search" type="text" width=1000px> 
                     <input type="submit" value="Science Search"/>
              </form>'''
@app.route('/people', methods=['POST'])
def PeopleSearch():
        name = request.form.get('search')
        print (name)

it gives an internal server error on clicking peoplesearch. This was working only a while back.

You do not return response for PeopleSearch endpoint. Next code must work fine:

@app.route('/people', methods=['POST'])
def people_search():
    name = request.form.get('search')
    return name

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM