如何在没有路由的情况下在 python flask 中执行正常函数并使用路由返回此过程的结果?

Pab*_*blo 5 python flask

该应用程序正在加载“links_submit.html”,其中有一个字段,您可以在其中编写链接,例如 (www.google.com) 并提交它,然后该应用程序会将此 URL 作为 HTTP Post 接收并重定向到另一个页面“post_response.html”,其中包含一个简单的 html,用于反馈“Ok”一词。然后我想用这个链接做一个过程(抓取谷歌并搜索特定的东西),完成这个过程后,自动从“post_reponse.html”重定向到另一个页面,以显示我从谷歌中提取的结果。现在我不确定如何在烧瓶上对我的应用程序说:“好的,现在让我们使用正常功能(不是路由),例如:

def loadpage(link_sent_by_the_http post):
   res = requests.get('www.google.com')
Run Code Online (Sandbox Code Playgroud)

想象一下,在加载页面后,我还在 google 上提取了一些 html 标签,在完成此过程后,我想将带有“ok”的页面“post_respose.html”重定向到一个新的 html 页面,其中包含从 google 中提取的 html 标签。请注意,我知道如何加载页面 google 并提取我想要的内容,但我不知道如何在 Flask 中间插入此函数/进程,然后从带有“ok”的普通 html 重定向到一条新路由我提取的结果。

import requests
from flask import Flask, render_template, request, url_for

app = Flask(__name__)

@app.route('/test')
def form():
   return render_template('links_submit.html')

@app.route('/links/', methods=['POST'])
def links():
    links=request.form['links']
    return render_template('post_response.html')

Intern Process (Load the received link > Extract what I want)
and then redirect the "post_response.html" to another "html" which will
contain the results that I have extracted) 

if __name__ == '__main__':
  app.run(debug=True)
Run Code Online (Sandbox Code Playgroud)