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 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据