2

Brython 是否有推荐的方法在服务器端使用相同的渲染代码?

为此,目前我正在使用我自己的browser模块在服务器端模拟 Brython 进行 html 渲染(https://github.com/yairchu/vote_tool/blob/master/browser.py),但我想知道是否有更好的方法..

4

1 回答 1

2

The portion of code you are using is short, elegant, and quite specific - it will be Python compatible on the server side, as you have noted, and you it won't be easy to find another piece of code for this kind of rendering that is so concise and able to work on Brython's client side (as it does not yet achieve 100% compatibility with Python).

That said, I think it is more than ok to reuse this code on the server side on your project.

Note that by carefully laying out files in your project directories, it is possible to have some files to be imported both on server and client side. If done correctly, this can make a great deal of work simpler.

于 2015-01-09T01:13:38.180 回答