Python I';当我尝试自动播放视频时,我的flask应用程序出现方法错误

Python I';当我尝试自动播放视频时,我的flask应用程序出现方法错误,python,html,flask,Python,Html,Flask,我正在运行一个flask应用程序,它可以自动播放视频,并在后台使用语音识别来识别用户在说什么(就像一个准互动应用程序),然后将用户重定向到一个定制的页面,显示他们的响应。不幸的是,我得到一个405错误,说视频文件方法是不允许的。我应该在这里使用Get方法吗?从html文档来看,它似乎负责处理视频文件 Python: from flask import render_template, Flask, request import os from vaderSentiment.vaderSentim

我正在运行一个flask应用程序,它可以自动播放视频,并在后台使用语音识别来识别用户在说什么(就像一个准互动应用程序),然后将用户重定向到一个定制的页面,显示他们的响应。不幸的是,我得到一个405错误,说视频文件方法是不允许的。我应该在这里使用Get方法吗?从html文档来看,它似乎负责处理视频文件

Python:

from flask import render_template, Flask, request
import os
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer as SIA
import nltk
import io
import os
from nltk.corpus import stopwords
import speech_recognition as sr

app = Flask(__name__)

# set the stopwords to be the english version
stop_words = set(stopwords.words("english"))
# create the recognizer
r = sr.Recognizer()
# define the microphone
mic = sr.Microphone(device_index=0)
r.energy_threshold = 300
# vader sentiment analyzer for analyzing the sentiment of the text
sid = SIA()


@app.route("/")
def home():
    return render_template('index.html')


@app.route("/get", methods=["GET", "POST"])
def user_info():
    name = ""
    location = ""
    state = ""
    info = [name, location, state]
    mic == source
    with mic as source:
        holder = []
        for x in info:
            audio_data = r.listen(source)
            r.adjust_for_ambient_noise(source)
            text = r.recognize_google(audio_data, language = 'en-IN')
            holder.append(text.lower())
            if x == "state":
                ss = sid.polarity_scores(holder)
                if ss == "neg":
                    x.append(str("sad"))
                else:
                    x.append(str("not sad"))
            else:
                filtered_words = [words for words in holder if not words in stop_words] # this filters out the stopwords
                x.append(filtered_words.lower())
    return render_template("list.html", user = name)

@app.route("/<name>", methods=["POST"])
def user_options():
    return render_template("list.html", user = name)

if __name__ == "__main__":    
    app.run(host='0.0.0.0')
从烧瓶导入渲染模板,烧瓶,请求
导入操作系统
从vadertouction.vadertouction将感伤强度分析器导入为SIA
导入nltk
输入io
导入操作系统
从nltk.corpus导入停止词
将语音识别作为sr导入
app=烧瓶(名称)
#将stopwords设置为英语版本
stop_words=set(stopwords.words(“英语”))
#创建识别器
r=高级识别器()
#定义麦克风
麦克风=高级麦克风(设备索引=0)
r、 能量阈值=300
#维德情绪分析器,用于分析文本情绪
sid=SIA()
@附件路线(“/”)
def home():
返回渲染模板('index.html')
@app.route(“/get”,methods=[“get”,“POST”])
def user_info():
name=“”
location=“”
state=“”
信息=[名称、位置、状态]
麦克风==源
以麦克风作为源:
持有人=[]
对于信息中的x:
音频数据=r.listen(源)
r、 调整环境噪声(源)
text=r.recognize\u谷歌(音频数据,语言='en-IN')
holder.append(text.lower())
如果x==“状态”:
ss=sid极性分数(保持器)
如果ss==“负”:
x、 附加(str(“sad”))
其他:
x、 附加(str(“not sad”))
其他:
filtered_words=[如果不是stop_words中的单词,则表示holder中的单词]#这将过滤掉stopwords
x、 追加(已过滤的单词.lower())
返回render_模板(“list.html”,user=name)
@app.route(“/”,methods=[“POST”])
def用户_选项():
返回render_模板(“list.html”,user=name)
如果名称=“\uuuuu main\uuuuuuuu”:
app.run(host='0.0.0.0')
HTML:

{%extends“base.html”%}
{%block content%}
治疗专家
{%endblock内容%}
{% extends "base.html" %}
{% block content %}

<!---------Therapist Section--------->
<section id="therapist">
  <div class="container" id="therapist_container">
    <h1 class="jumbotron text-center" id="chatbot_title">Therapist</h1>
          <div id="vid">
            <video width="320" height="240" autoplay>
              <source src="movie.mp4" type="video/mp4">
              <source src="movie.mov" type="video/ogg">
            </video>
          </div>
    </div>
</section>

{% endblock content %}