GithubHelp home page GithubHelp logo

flask-websocket-vue-demo's Introduction

Vue and Flask SocketIO 简单示例

Backend后端

Prerequisites

python3.9 (推荐conda构建一个新的环境)

pip install -r requirements.txt

Version compatibility

socketIO依赖于多个库,要能够正常使用的话,需要正确的安装对应依赖库的版本,当前代码中使用的是中间的那个

详细信息可以参考:https://flask-socketio.readthedocs.io/en/latest/intro.html#version-compatibility

JavaScript Socket.IO version Socket.IO protocol revision Engine.IO protocol revision Flask-SocketIO version python-socketio version python-engineio version
0.9.x 1, 2 1, 2 Not supported Not supported Not supported
1.x and 2.x 3, 4 3 4.x 4.x 3.x
3.x and 4.x 5 4 5.x 5.x 4.x

运行

进入到backend目录下,运行app.py:

cd backend
python app.py

Fronted 前端

Prerequisites

安装yarn

conda install yarn

运行前端

进入到fronted目录下. 运行一下的命令. 然后在浏览器中打开

cd fronted
yarn install
yarn run serve --port 8111

# http://your_ip:8111

注意:若修改了后端的端口,需要在fronted/src/components/HelloWorld.vue中也修改后端的端口

打开前端的界面,在建立了socket连接后,后端会不断的向前端推送一些随机数字显示

1664029291799

注:前后端是分别独立运行

References

  1. https://github.com/iodriller/VueJs-Flask-SocketIO-Example-Templatehttps://github.com/bioudi/Flask-VueJs-SocketI 做了一些简化

flask-websocket-vue-demo's People

Contributors

skane1024 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.