How Python is used to create web services?

旧街凉风 提交于 2019-12-11 08:25:27

问题


I always created my web services using PHP but I am interested in switching to Python because of its simplicity. On my web server (I have created a "tmp.py") just with one line:

print "Hello!"

And then I have opened this file in my browser. I was surprised that it works (I saw "Hello!"). But there are two more thinks that I need to know:

  1. How do I access the get and post variables as well as the session?
  2. How do I use databases from python. Does Python connects to MySQL server like PHP does or some other approach is used?

回答1:


HOWTO Use Python in the web is the official Python manual on this matter. It's a fairly good starting point, giving a brief overview on the subject, and listing the most common options:

  • CGI and CGI spin-offs (Fast CGI, WSGI)
  • mod_python
  • Full frameworks, most notably Django

Although I admire Python for its elegance and power, it's far from being the natural or standard choice for web development. Carefully consider the use case, and who will maintain the code, before picking the language.



来源:https://stackoverflow.com/questions/9382479/how-python-is-used-to-create-web-services

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!