开发者

python script output to webpage

开发者 https://www.devze.com 2023-01-25 05:42 出处:网络
I wrote a python script 开发者_如何学Pythonthat reads in text from a file and writes a text file of definitions. I want to somehow integrate my program with a webpage for the whole world to see.

I wrote a python script 开发者_如何学Pythonthat reads in text from a file and writes a text file of definitions. I want to somehow integrate my program with a webpage for the whole world to see.

I want to be able to retrieve input text from one text box, have the python script process it, then display the output in the other text box.

I have done quite a bit of research thus far but I am still unsure of the best way to go about doing this. I tried using google's app engine but encountered too many problems, for example the app engine runtime environment uses python 2.5.2, I wrote my program using 3.1.2. Other than that I just felt that I was beginning to waste my time trying to port my program over.

I'm starting to think that javascript is the way to go or maybe pyjamas. I was also wondering if it would be possible to just have the python program constantly running on the server and to perform a system call.

I posses very little knowledge when it comes to web development. I appreciate any advice.


You could use the cgi module and create a CGI script, if your server supports it.


It's a much bigger question, involving:

  • Where are you going to host the site,
  • How slow is the script (can it execute in a few seconds or not),
  • Does it need access data from files or a database,
  • How complex is it,
  • etc.

I would suggest you read about Django:

  • http://docs.djangoproject.com/en/1.2/

That is probably the easiest way to set up a simple web site, but is also very powerful if you want to do something more in the future (related to this project or not).

However, since your script is Python 3 only, you don't have too many options, see this question:

  • https://stackoverflow.com/questions/373945/what-web-development-frameworks-support-python-3

I suppose, if not too hard, it is worth thinking about converting it to Python 2.7.

If that is an option, then you might very well go down to Python 2.5 and use Google App Engine. It gives you many things for free and you really don't need to worry about many things that you would if you were to set up your server. It includes a modified (better to say, shrunk down) version of Django 1.1. When you say you are wasting your time porting from 3.x to 2.5, I guess you were not counting the time that you will waste setting all other things up.

0

精彩评论

暂无评论...
验证码 换一张
取 消