Python 输入搜索词或图像url时Flask和Clarifai API不工作

Python 输入搜索词或图像url时Flask和Clarifai API不工作,python,python-2.7,flask,clarifai,Python,Python 2.7,Flask,Clarifai,我刚刚在YouTube上完成了关于Clarifai API和Flask的简短教程,但当我尝试在屏幕上的任何输入位置输入搜索结果时,我的web应用程序都无法工作http://localhost:5000/ 因为在输入我的搜索词或图像url后没有显示任何内容。也就是说,index.html正在显示,但是,例如,当我尝试在第一次输入中输入'animal'并按下'search'按钮时,什么都没有发生 下面是回溯、代码本身和我的目录结构。任何帮助都将不胜感激 回溯 测试.py index.html 您是否

我刚刚在YouTube上完成了关于Clarifai API和Flask的简短教程,但当我尝试在屏幕上的任何输入位置输入搜索结果时,我的web应用程序都无法工作http://localhost:5000/ 因为在输入我的搜索词或图像url后没有显示任何内容。也就是说,index.html正在显示,但是,例如,当我尝试在第一次输入中输入'animal'并按下'search'按钮时,什么都没有发生

下面是回溯、代码本身和我的目录结构。任何帮助都将不胜感激

回溯

测试.py

index.html

您是否将输入(图像)插入到您正在使用的Clarifai应用程序中

/usr/local/bin/python3.8 /Users/lyons/Desktop/testing.py
 * Serving Flask app "testing" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [25/Sep/2020 11:45:03] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [25/Sep/2020 11:45:10] "POST / HTTP/1.1" 200 -

from clarifai.rest import ClarifaiApp
from flask import Flask, request, render_template
clarifaiKEY = 'REDACTEDFORPRIVACY'

myAI = ClarifaiApp(api_key=clarifaiKEY)
app = Flask(__name__)

@app.route('/')
def index():
    return render_template('/index.html', len=0)

@app.route('/', methods=['POST'])
def search():
    if request.form['searchByConcept']:
        searchTerm = request.form['searchByConcept']
        searchResults = myAI.inputs.search_by_predicted_concepts(concept=searchTerm)
        return render_template('/index.html', len=len(searchResults), searchResults=searchResults)
    elif request.form['searchByImage']:
        refImage = request.form['searchByImage']
        searchResults = myAI.inputs.search_by_image(url=refImage)
        return render_template('/index.html', len=len(searchResults), searchResults=searchResults)

if __name__ == '__main__':
    app.run(host='0.0.0.0')
<h1>Can I help you find something?</h1>

<form action="." method="post">
    <h2>Search By Concept</h2>
        <input type="text" name="searchByConcept">
        <input type="submit" name="searchByConcept" value="Search">
    <h2>Search By Image</h2>
        <input type="text" name="searchByImage" >
        <input type="submit" name="searchByImage" value="Search">
</form>

{%for i in range(0,len)%}
<li><img src="{{searchResults[i].url}}" alt=""></li>
{%endfor%}
/testing.py
/templates
    /index.html