Python is integrated with ASP framework

Source: Internet
Author: User

I. ASP is like ASP. Many people say that "asp is a tough language, it cannot be object-oriented, it has a single function, and many things cannot be implemented. The above statements are all incorrect. ASp is not a language, but a web framework that Microsoft uses to replace CGI. However, we have been distorted in vbs, which is the default language of asp, equals the number between ASP and vbs. The second Asp function is actually not simple. This web provides five objects (request, response, server, session, appliaction). This is what asp is born, all of these are script-level items used by Asp. ASP uses Asp. dll dynamic link library. In theory, you can try all script languages including vbscript, jsscript, actionscript, perl, and python ), therefore, ASP is a rich and flexible web framework. 2. Why is it so popular to use python to write Asp python? It plays an important role in all major fields, he is also indispensable in the web aspect. Echosong has used python web frameworks such as django and web. py. Because of work requirements, Echosong is mostly written in ASP. However, the Asp of vbs makes people feel anxious to write, and it is difficult to consider the stability of many functions written in c or other languages, the echosong is a full fan of Python, and it has been a hobby that has never been interrupted since, but it has never been used to work. 3. integrate the two partners. 1. asp installation: with IIS installation, asp becomes the web framework installed by default. 2. Install activepython: activePython is a specialized Python programming and debugging tool launched by ActiveState. ActivePython contains a complete Python kernel, which directly calls the official Python open-source kernel. In addition, there is also the IDE required for Python programming, and some Python Windows extensions are attached, it also provides all services for accessing Windows APIs. Although ActivePython is not as open-source as pure Python, it can be downloaded for free. (Note that only version 2.5 can be downloaded. At the beginning, echosong cannot download version 2.7. The result of the relentless version 500 is unclear. The version 2.5 is enough) 3. Run C: \ Python25 \ Lib \ site-packages \ win32comext \ axscript \ client \ pyscript on the command line. py; 4. After completing the above two steps, you can write python Asp. 4. Connect the database file conn with a simple Demo. asp (use pymssql to connect to the mssql database) <% import pymssqlclass MSSQL: def _ init _ (self, host, user, pwd, db): self. host = host self. user = user self. pwd = pwd self. db = db def _ GetConnect (self): if not self. db: Respons E. write (NameError, "No connec Info") self. conn = pymssql. connect (host = self. host, user = self. user, password = self. pwd, database = self. db, charset = "utf8") cur = self. conn. cursor () if not cur: Response. write (NameError, "connect Err") else: return cur def getCur (self): return self. _ GetConnect () def ExecQuery (self, SQL): cur = self. _ GetConnect () cur.exe cute (SQL) resList = cur. fetchall () self. conn. close () retur N resList def ExecNonQuery (self, SQL): cur = self. _ GetConnect () cur.exe cute (SQL) self. conn. commit () self. conn. close () gmssql = MSSQL (host = "*****", user = "*****", pwd = "***", db = "***") gcur = MSSQL. getCur () %> here we can freely import python-related modules !!! The data. asp file calls the conn. asp data connection to execute an SQL statement to display the field value cyclically to the page <% @ LANGUAGE = "python" CODEPAGE = "65001" %> <! -- # Include file = "conn. asp" --> <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.