小编Far*_*nii的帖子

number of threads in flask

i just learn about flask and requests. i want to get the number of working threads when i post request to the server. and i want to measure the time spent of the working threads. so this is my server and my client code:

server.py

from flask import Flask
from flask import request
import time 
from flaskthreads import AppContextThread

app = Flask(__name__)

@app.route("/", methods = ['GET', 'POST'])

def home():
    timeout = time.time() + 10   # 5 minutes from now

    while …
Run Code Online (Sandbox Code Playgroud)

python multithreading flask

5
推荐指数
1
解决办法
3113
查看次数

如何防止值错误:flask socketio 中有效负载中的数据包过多

所以我正在做我的期末项目。我想从客户端网络摄像头获取头部姿势估计。我使用 websocket 成功将网络摄像头传输到服务器。但是当我尝试将头部姿势函数放入套接字路径中时,终端valueError: too many packets in payload经常显示错误。有谁知道如何防止这个错误?任何答案将不胜感激。谢谢 !

这是我的代码以获取更多信息。

JavaScript

var constraints = { audio: false, video: { width: 500, height: 500 } }; 
var video = document.querySelector('video');
var canvas = document.querySelector('canvas');

var socket = io('https://0.0.0.0:8000');

navigator.mediaDevices.getUserMedia(constraints)
    .then(function(mediaStream) {
    video.srcObject = mediaStream;
    video.onloadedmetadata = function(e) {
    video.play();

  };
})
.catch(function(err) { console.log(err.name + ": " + err.message); })

socket.on('connect', function () {
    console.log('connected !', socket.connected);

    function capture() {
        canvas.width = 200;
        canvas.height = 200;
        canvas.getContext('2d').drawImage(video, 0, 0, …
Run Code Online (Sandbox Code Playgroud)

javascript websocket flask-socketio

5
推荐指数
1
解决办法
4487
查看次数

本地存储数据未呈现

目前我正在制作一个电子商务网站。我想将用户的订单数据存储在本地存储上。这是我的代码:

详情.vue

import DataService from '../web_service/services'

export default {
  name: 'details',
  props: ['userId'],
  data () {
    return {
      datas: null,
      url: '/' + this.userId,
      value: 1
    }
  },
  created () {
    DataService.getFindById(this.url)
      .then((res) => {
        this.datas = res.data.data
      })
      .catch((err) => {
        alert('error when fetching API' + err)
      })
  },
  methods: {
    buyNow () {
      let order = {
        product: this.datas.name,
        price: this.datas.price,
        quantity: this.value
      }

      this.$store.commit('addOrder', order)
      this.$router.push('/cart')
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

商店.js

import Vue from 'vue'
import Vuex from …
Run Code Online (Sandbox Code Playgroud)

javascript vue.js vue-component vuex vuejs2

1
推荐指数
1
解决办法
50
查看次数