简体   繁体   English

使用python将文本打印到网页

[英]printing text to webpage using python

I want to know; 我想知道; is this possible? 这可能吗? I learnt HTML back in the early 00s, used to have the fundamentals of PHP and javascript. 我在00年代早期学习过HTML,过去常常使用PHP和javascript的基础知识。 Now all I remember is basic HTML, and python. 现在我记得的只是基本的HTML和python。 Currently I have a python script that prints to a GUI Tkinter entry on repeat every couple of seconds, as defined by the user. 目前我有一个python脚本,按照用户的定义,每隔几秒重复打印一次GUI Tkinter条目。

I want to do this with a webpage. 我想用网页做这件事

Is it possible to print text to a dynamically updated webpage? 是否可以将文本打印到动态更新的网页? I was thinking RSS feed.. which sure, would work. 我在想RSS feed ..肯定会有用。 But it probably wouldn't be to neat. 但它可能不会整洁。 I want to recreate my Tkinter GUI on a page and make the 'flashcard' service available on the net. 我想在页面上重新创建我的Tkinter GUI,并在网上提供“flashcard”服务。 The python script retrieves values from an SQL Lite database. python脚本从SQL Lite数据库中检索值。 And as I hear python is net-safe, I don't want to learn an entirely new language such as PHP. 正如我听说python是网络安全的,我不想学习一种全新的语言,比如PHP。

I would also like to embed the entire dynamically updated form in a drupal site if it's possible to do that. 如果有可能,我还想在drupal站点中嵌入整个动态更新的表单。 Any ideas? 有任何想法吗? Example tutorials on using python to dynamically add text to a webpage? 使用python动态添加文本到网页的示例教程?

Perhaps you're trying to create a CGI script? 也许你正在尝试创建一个CGI脚本? http://en.wikipedia.org/wiki/Common_Gateway_Interface http://en.wikipedia.org/wiki/Common_Gateway_Interface

Here is a python specific tutorial for CGI programming: http://www.tutorialspoint.com/python/python_cgi_programming.htm 这是一个用于CGI编程的python特定教程: http//www.tutorialspoint.com/python/python_cgi_programming.htm

While @fulhack recommends the CGI python module, and I personally have used this in the past, its not quite an optimal choice these days. 虽然@fulhack推荐使用CGI python模块,而我个人过去曾经使用过这个模块,但这些日子并不是最佳选择。 Its pretty inefficient, since a new python process has to be started per request (if I remember correctly). 它非常低效,因为每个请求都必须启动一个新的python进程(如果我没记错的话)。

What you might want to do, to get yourself going down the right path to start, is take a look at the abundant choices for python web frameworks: 你可能想做什么,让自己走上正确的道路,开始,看看python web框架的丰富选择:
http://wiki.python.org/moin/WebFrameworks http://wiki.python.org/moin/WebFrameworks

Some are quite large and full featured like django. 有些很大,像django一样功能齐全。 While others are very lightweight and small. 而其他人则非常轻巧小巧。 I hear flask is pretty light, though all I personally have much experience with is django. 我听说烧瓶很轻,虽然我个人有很多经验就是django。 If you compare some of these and pick one that suits your needs, you may be a lot happier in the long run and and up learning a process that is reusable. 如果你比较其中的一些并选择一个适合你的需求,从长远来看你可能会更开心,并且可以学习一个可重复使用的过程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM