首页 > 解决方案 > 如何在 Python 中将输入函数与烧瓶一起使用,以捕获用户输入,然后根据该响应发送响应。像对话流

问题描述

如何在 Python 中将输入函数与烧瓶一起使用,以获取用户输入,然后根据该响应发送响应。尝试连续执行此操作,例如对话流方法。

试图公开此命令行终端以捕获 UI 中的用户输入捕获

#Below is the code
df_final = pandas_dedupe.dedupe_dataframe(df,['Company'])
#Below is the resultant output which get displayed in terminal which asks for user response. 
#I'm trying to expose this to user and get his response.
Company : reliance captal

Company : reliance captive

0/10 positive, 0/10 negative
Do these records refer to the same thing?
(y)es / (n)o / (u)nsure / (f)inished

标签: pythonpython-3.xflaskflask-wtformspython-webbrowser

解决方案


模板/contact.html

<form action="/contact" method="POST">
  <textarea type="text" name="msg"></textarea>
  <label>Messege</label>
  <button type="submit" class="button buttonBlue">
  Submit
  </button>
</form>

app.py
数据存储在msg变量中,您可以根据该变量发送响应

@app.route('/contact', methods=['GET', 'POST'])
def contact():
    if request.method == 'POST':
        msg = request.form.get('msg')
    return render_template("contact.html")


推荐阅读