def search(): if request.method=='POST': searchdialogue=request.form.get('dialogue','xxxxdkz') if searchdialogue!='xxxxdkz': movie=dodata.search(searchdialogue) if len(movie)>0 and movie[0][1]>3: movieId=movie[0][0] movieNum=movie[0][1] movieInfo=dodata.getMovieInfo(movieId) dialogueArr=[dodata.getOneDialogue(movieId,movieNum-2),dodata.getOneDialogue(movieId,movieNum-1),dodata.getOneDialogue(movieId,movieNum),dodata.getOneDialogue(movieId,movieNum+1),dodata.getOneDialogue(movieId,movieNum+2),dodata.getOneDialogue(movieId,movieNum+3),dodata.getOneDialogue(movieId,movieNum+4)] resp={'flag':'ok','name':movieInfo[0],'director':movieInfo[1],'actor':movieInfo[2],'image':movieInfo[3],'dialogue':dialogueArr} else: resp={'flag':'fail'} else: resp={'flag':'fail'} return render_template('response.html',resp=resp) else: resp=Markup("""<h4> 于是,词语和词语的距离变得无比遥远,段落与段落间成了无尽的留白。 我正站在留白里站在词语彼此遥远的距离间。</h4> <h2>请输入 对白 关键词查询</h2> <form name="input" action="/search" method="post"> <input class="input" type="text" name="dialogue" /> <input class="btn" type="submit" value="Search" /> </form> """) return render_template('template.html',resp=resp)
def jump(): searchdialogue=request.args.get('q','xxxxdkz') if searchdialogue!='xxxxdkz': movie=dodata.search(searchdialogue) if len(movie)>0 and movie[0][1]>3: movieId=movie[0][0] movieNum=movie[0][1] movieInfo=dodata.getMovieInfo(movieId) dialogueArr=[dodata.getOneDialogue(movieId,movieNum-2),dodata.getOneDialogue(movieId,movieNum-1),dodata.getOneDialogue(movieId,movieNum),dodata.getOneDialogue(movieId,movieNum+1),dodata.getOneDialogue(movieId,movieNum+2),dodata.getOneDialogue(movieId,movieNum+3),dodata.getOneDialogue(movieId,movieNum+4)] resp={'flag':'ok','name':movieInfo[0],'director':movieInfo[1],'actor':movieInfo[2],'image':movieInfo[3],'dialogue':dialogueArr} else: resp={'flag':'fail'} else: resp={'flag':'fail'} return jsonify(resp)