烧瓶 - 等到磁盘安装完毕 [英] Flask - wait until disk is mounted

查看:124
本文介绍了烧瓶 - 等到磁盘安装完毕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将我的控制台应用程序移动到Flask,但是我是这个框架的新手。
我首先需要做的是启动应用程序,并显示一个等待页面,直到磁盘被挂载。挂载成功后,应用程序应该重定向到主索引页面。



任何线索?
谢谢

解决方案

您可以首先返回一个等待页面给用户。而且您可以对Flask服务器执行ajax请求来轮询您的任务(安装磁盘)的状态。当您在ajax响应中获取磁盘时,您可以重定向到主索引页面。

或者您可以使用websocket来通知您的任务的状态。有一个扩展名为 Flask-SocketIO 为你实现websocket。


I am trying to move my console app to Flask but I am new to this framework. What I first need to do is to launch the application and show a "waiting" page until a disk is mounted. When the mount succeeds, the application should redirect to the main index page.

Any clue? Thanks

解决方案

You can return a waiting page to user at first. And you can do ajax request to your Flask server to polling the status of your task(mount disk). When you get disk mounted in ajax response, You can redirect to main index page.

Or you can use websocket to inform the status of your task. There is a extension named Flask-SocketIO implement websocket for you.

这篇关于烧瓶 - 等到磁盘安装完毕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆