简体   繁体   中英

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. Now all I remember is basic HTML, and 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.

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. 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. The python script retrieves values from an SQL Lite database. And as I hear python is net-safe, I don't want to learn an entirely new language such as PHP.

I would also like to embed the entire dynamically updated form in a drupal site if it's possible to do that. Any ideas? Example tutorials on using python to dynamically add text to a webpage?

Perhaps you're trying to create a CGI script? 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

While @fulhack recommends the CGI python module, and I personally have used this in the past, its not quite an optimal choice these days. Its pretty inefficient, since a new python process has to be started per request (if I remember correctly).

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:
http://wiki.python.org/moin/WebFrameworks

Some are quite large and full featured like django. While others are very lightweight and small. I hear flask is pretty light, though all I personally have much experience with is 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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