2017-08-15 102 views
1
页面

我有一个流媒体服务器为我的树莓派启动脚本树莓派。我希望能够从网站伺服器(云台)进行控制。因此,我想开始一个python脚本,当被压在网站钮,而无需刷新页面开始。有没有办法做到这一点?我正在使用烧瓶。没有刷新

+0

忘了mension,我使用Python – estrella1995

回答

0

你想设置一个端点在瓶中的应用程序,如:

from flask import Flask 
app = Flask(__name__) 

@app.route("/") 
def indexpage(): 
    # Serve your index web page here 
    return app.send_static_file('index.html') 

@app.route("/runscript") 
def runscript(): 
    # Do whatever you want here 
    run_my_script() 

app.run() 

然后在你的网页具有在runscript端点发送GET请求对您的应用形式。

<form action="/runscript" method="get"> 
 
    <input type="submit" value="Submit"> 
 
</form>

+0

谢谢你的回答!当我使用'app.send_static_file'我得到“未找到”。我的代码如下所示: – estrella1995

+0

'@ app.route( '/') 高清指数(): 回报render_template( '的index.html') @ app.route( '/上/')\t 高清起来(): \t control.up() \t返回render_template( '的index.html') \t DEF根(照相机): 而真: 帧= camera.get_frame() 收率(b' - frame \ r \ n' b'Content-Type:image/jpeg \ r \ n \ r \ n'+ frame + b'\ r \ n') @ app.r欧特( '/ video_feed') DEF video_feed(): 返回响应(根(摄像机()),MIME类型 ='多部分/ X - 混合取代;边界=帧 ') 如果__name__ == '__main__': app.run(主机=' 0.0.0.0' ,螺纹=真)' – estrella1995