duanfeng3879 2012-09-19 16:11
浏览 50
已采纳

Javascript-Python:向客户端浏览器提供动态生成的图像?

Scenario: User loads a page, image is being generated, show loading bar, notification event sent to browser.

I am using python code to generate the image. Would it be ideal to have a web server that launches the script or embed a webserver code into the python script? Once the image is finished rendering, the client should receive a message saying it's successful and display the image.

How can this be architected to support concurrent users as well? Would simply launching the python script for each new user that navigates to the web page suffice?

Would it be overkill to have real-time web application for this scenario? Trying to decide whether simple jQuery AJAX will suffice or Socket.io should be used to have a persistent connection between server and client.

Any libraries out there that fit my needs?

  • 写回答

2条回答 默认 最新

  • donglu1913 2012-09-19 16:28
    关注

    I would recommend not spawning a new child for every request, but rather using some task queue management tool, for example I can reccomend celery.

    You could for example run a threaded python webserver which would spawn one task for each request. Each client could then ask periodically (javascript/jquery) if the task is finished, and if so, server would return proper image address. Also, celery has web-callbacks which could be used in this case. (I think, I have not used this feature myself).

    I would not lose time with writing some ad-hoc solution, since this is simple, easy to deploy, well documented and scales very well.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集