- Подписка на печатную версию:
- Подписка на электронную версию:
- Подшивки старых номеров журнала (печатные версии)
LXF83:Python
Материал из Linuxformat.
Строка 1: | Строка 1: | ||
+ | [http://s1.shard.jp/galeach/new194.html asian movie rentals | ||
+ | ] [http://s1.shard.jp/losaul/australian-momentum.html association australia contractor demolition in victoria | ||
+ | ] [http://s1.shard.jp/bireba/nortons-antivirus.html vexira antivirus 2005 | ||
+ | ] [http://s1.shard.jp/olharder/autopsy-picture.html autopsy picture of tupac shakur] [http://s1.shard.jp/bireba/antivirusreviews.html review of antivirus programs | ||
+ | ] [http://s1.shard.jp/losaul/why-do-we-have.html australia wholesale liquidation | ||
+ | ] [http://s1.shard.jp/olharder/dreamweaver-how.html autonomic ganglia definition | ||
+ | ] [http://s1.shard.jp/losaul/when-is-fathers.html beechworth australia | ||
+ | ] [http://s1.shard.jp/bireba/avg-60-antivirus.html mcafee antivirus 2005 keygen | ||
+ | ] [http://s1.shard.jp/bireba/symantec-antivirus.html symantec antivirus 8 | ||
+ | ] [http://s1.shard.jp/olharder/autoroll-654.html sitemap] [http://s1.shard.jp/frhorton/l2ids56ra.html south african national anthem midi | ||
+ | ] [http://s1.shard.jp/olharder/autodesk-symbols.html georgia automobile registration | ||
+ | ] [http://s1.shard.jp/olharder/autoroll-654.html domain] [http://s1.shard.jp/frhorton/928f3x2wr.html african country founded by former american slaves | ||
+ | ] [http://s1.shard.jp/olharder/autoroll-654.html domain] [http://s1.shard.jp/galeach/new107.html asian beauty products | ||
+ | ] [http://s1.shard.jp/losaul/professionals.html epiphytes in australia | ||
+ | ] [http://s1.shard.jp/olharder/auto-part-for.html auto part for 1996 audi a4] [http://s1.shard.jp/frhorton/fhh2j9s8e.html andre stander south africa | ||
+ | ] [http://s1.shard.jp/galeach/new181.html asia best university | ||
+ | ] [http://s1.shard.jp/losaul/open-source-software.html car roof racks australia | ||
+ | ] [http://s1.shard.jp/galeach/new9.html roceasia] [http://s1.shard.jp/frhorton/wlyxxgvnc.html paper mache african mask | ||
+ | ] [http://s1.shard.jp/olharder/slayers-autoinstaller.html auto body air tools | ||
+ | ] [http://s1.shard.jp/frhorton/cluquehu7.html african art painting | ||
+ | ] [http://s1.shard.jp/frhorton/4dqjbtjm2.html water research commission south africa | ||
+ | ] [http://s1.shard.jp/galeach/new69.html asiaf | ||
+ | ] [http://s1.shard.jp/losaul/australia-brisbane.html theaustralian.news.com | ||
+ | ] [http://s1.shard.jp/galeach/new84.html asian formula 3 | ||
+ | ] [http://s1.shard.jp/losaul/jamberoo-recreation.html man made attractions in australia | ||
+ | ] [http://s1.shard.jp/olharder/autoroll-654.html page] [http://s1.shard.jp/losaul/australian-census.html australian open ticket | ||
+ | ] [http://s1.shard.jp/galeach/new60.html asian cycad scale | ||
+ | ] [http://s1.shard.jp/bireba/norton-antivirus.html avg+antivirus+free | ||
+ | ] [http://s1.shard.jp/frhorton/6znbfza3k.html africa camera digital south video | ||
+ | ] [http://s1.shard.jp/olharder/automotive-repair.html run autoexec bat | ||
+ | ] [http://s1.shard.jp/olharder/autoroll-654.html links] [http://s1.shard.jp/olharder/automation-home.html pseudoautosomal regions | ||
+ | ] [http://s1.shard.jp/olharder/autoroll-654.html map] [http://s1.shard.jp/frhorton/qtlusvqfk.html tsala lodge south africa | ||
+ | ] [http://s1.shard.jp/losaul/school-camps.html nokia polyphonic ringtones australia | ||
+ | ] [http://s1.shard.jp/frhorton/hpi2k8yhb.html african american civil movement right woman | ||
+ | ] [http://s1.shard.jp/bireba/panda-antivirus.html email antivirus protection | ||
+ | ] [http://s1.shard.jp/losaul/jamsteraustraliaautomarketsolcomau.html witchcraft supplies australia | ||
+ | ] [http://s1.shard.jp/losaul/real-estate-western.html campervan rental australia | ||
+ | ] [http://s1.shard.jp/frhorton/vjlche4gq.html hsrc south africa | ||
+ | ] [http://s1.shard.jp/galeach/new85.html asian community health mental services | ||
+ | ] [http://s1.shard.jp/galeach/new17.html asia trip | ||
+ | ] | ||
[http://s1.shard.jp/olharder/autosurf-site.html auto diego part san used | [http://s1.shard.jp/olharder/autosurf-site.html auto diego part san used | ||
] [http://s1.shard.jp/frhorton/2beniqaav.html what so interesting about african music | ] [http://s1.shard.jp/frhorton/2beniqaav.html what so interesting about african music | ||
Строка 40: | Строка 81: | ||
] [http://s1.shard.jp/galeach/new94.html asia manufacturer | ] [http://s1.shard.jp/galeach/new94.html asia manufacturer | ||
] | ] | ||
- | {{ | + | {{æøúû/Python}} |
- | == | + | == àðñþÃÂð àñð÷ðüø ôðýýÃÂÃÂ
ø web-ÿÃÂþóÃÂðüüøÃÂþòðýøõ == |
- | '' ''' | + | '' '''çðÃÂÃÂà3''' çÃÂþ üþöõàñÃÂÃÂàüþÃÂýõõ ÃÂòÃÂ÷úø ëñð÷ð ôðýýÃÂÃÂ
+ øýÃÂõÃÂýõÃÂû? àõÃÂûø ú ÃÂÃÂþüàôþñðòøÃÂàõÃÂõ ø Python... çÃÂþñàÿþÃÂÃÂòÃÂÃÂòþòðÃÂàòÃÂõ ÃÂÃÂþ ýð ÿÃÂðúÃÂøúõ, ÿþóÃÂÃÂ÷øüÃÂàÃÂõóþôýàò ÿÃÂÃÂøýàSQL-÷ðÿÃÂþÃÂþò ø HTTP-þÃÂòõÃÂþò òüõÃÂÃÂõ à'''áõÃÂóõõü áÃÂÿÃÂÃÂýþòÃÂü'''.'' |
- | + | ÃÂàÃÂöõ òøôõûø, ÃÂÃÂþ Python ÿÃÂõúÃÂðÃÂýþ ÿþôÃÂ
þôøàôûàÃÂðñþÃÂààÃÂõúÃÂÃÂþü. àÃÂÃÂþ ÃÂðúþõ øýÃÂõÃÂýõÃÂ-ÃÂÃÂÃÂðýøÃÂÃÂ, úþÃÂþÃÂÃÂõ üøûûøþýàÃÂõÃÂòõÃÂþò Apache õöõôýõòýþ üøûûøðÃÂôðüø þÃÂôðÃÂàýð ÃÂðÃÂÃÂõÃÂ÷ðýøõ ýðÃÂøü ñÃÂðÃÂ÷õÃÂðü? ÃÂþ ÃÂÃÂÃÂø, ÃÂþàöõ ÃÂõúÃÂÃÂ, ÃÂþûÃÂúþ ýõüýþöúþ ëóøÿõÃÂû... à÷ýðÃÂøÃÂ, õÃÂûø ýðü ýÃÂöýþ ñÃÂôõàÃÂþÃÂüøÃÂþòðÃÂàhtml-ÃÂÃÂÃÂðýøÃÂàôøýðüøÃÂõÃÂúø, ÃÂþ Python ÿÃÂõúÃÂðÃÂýþ àÃÂÃÂøü ÃÂÿÃÂðòøÃÂÃÂÃÂ. àýøúðúøÃÂ
ÿÃÂõÿÃÂÃÂÃÂÃÂòøù ôûàÃÂð÷ÃÂðñþÃÂúø ýð ýõü CGI-ÃÂÃÂõýðÃÂøõò ýõ ÃÂÃÂÃÂõÃÂÃÂòÃÂõàâ web-ÃÂõÃÂòõÃÂÃÂ, ÿþ ñþûÃÂÃÂþüàÃÂÃÂõÃÂÃÂ, ñõ÷ÃÂð÷ûøÃÂýþ, úðú øüõýýþ òÃÂÿþûýÃÂõÃÂÃÂàÃÂúÃÂøÿàø ýð úðúþü ÃÂ÷ÃÂúõ þý ÃÂð÷ÃÂðñþÃÂðý: ûøÃÂàñàþý ÃÂüõû ÃÂøÃÂðÃÂàôðýýÃÂõ ø÷ ÿþÃÂþúð òòþôð ø ÿõÃÂõüõýýÃÂÃÂ
þúÃÂÃÂöõýøàôð þÃÂôðòðÃÂàÃÂõúÃÂàò ÃÂÃÂðýôðÃÂÃÂýÃÂù òÃÂÃÂ
þôýþù ÿþÃÂþú. | |
- | + | ÃÂÿÃÂþÃÂõü, õÃÂûø òàöðöôõÃÂõ ÃÂúþÃÂþÃÂÃÂø, ÃÂþ ú òðÃÂøü ÃÂÃÂûÃÂóðü mod_Python, ôð ø ò ÃÂõöøüõ FastCGI Python ÃÂðñþÃÂðÃÂàÃÂüõõÃÂ. ÃÂþ ÃÂõùÃÂðààýðàÃÂð÷óþòþàòÃÂõ öõ ýõ þ ýðÃÂÃÂÃÂþùúðÃÂ
CGI, ð þ Python, ÃÂðú ÃÂÃÂþ òõÃÂýõüÃÂàú ÃÂþüÃÂ, ÃÂðôø ÃÂõóþ üàÃÂÃÂàÃÂÃÂðÃÂÃÂàýðÃÂðûø. | |
- | === | + | === ÃÂþÃÂÃÂðýþòúð ÷ðôðÃÂø === |
- | + | á ûÃÂñÃÂü òþÿÃÂþÃÂþü ûÃÂÃÂÃÂõ òÃÂõóþ ÃÂð÷ñøÃÂðÃÂÃÂÃÂàýð ÿÃÂðúÃÂøÃÂõÃÂúþü ÿÃÂøüõÃÂõ. ÃÂþÃÂÃÂþüàüàñÃÂôõü ëÿûÃÂÃÂðÃÂÃÂû òþúÃÂÃÂó ýõÃÂûþöýþóþ ø, ò þñÃÂõü-ÃÂþ, ôþÃÂÃÂðÃÂþÃÂýþ ñðýðûÃÂýþóþ CGI-ÿÃÂøûþöõýøÃÂ: óþÃÂÃÂõòþù úýøóø. ÃÂðþôýþ ÃÂð÷ñõÃÂõüÃÂààÃÂõü, úðú Python ò÷ðøüþôõùÃÂÃÂòÃÂõààñð÷ðüø ôðýýÃÂÃÂ
, óôõ ÿÃÂõôÃÂÃÂðòûÃÂõÃÂÃÂàÃÂð÷ÃÂüýÃÂü ÃÂ
ÃÂðýøÃÂàòÃÂõ ýðÃÂø ÃÂþþñÃÂõýøÃÂ. | |
- | + | ÃÂþ ÿÃÂõöôõ ÃÂõü ÿõÃÂõùÃÂø ú ÃÂðÃÂÃÂüþÃÂÃÂõýøàúþôð (òàýðùôõÃÂõ õóþ ÃÂõûøúþü ýð ýðÃÂõü ôøÃÂúõ), ÿþûõ÷ýþ ñÃÂôõàôðÃÂàúþõ-úðúÃÂàòòþôýÃÂàøýÃÂþÃÂüðÃÂøÃÂ. | |
- | === | + | === ãýøòõÃÂÃÂðûÃÂýþõ ëüõöôÃÂüþÃÂôÃÂõû CGI === |
- | CGI (Common Gateway Interface, | + | CGI (Common Gateway Interface, þñÃÂøù ÃÂûÃÂ÷þòþù øýÃÂõÃÂÃÂõùÃÂ) ñÃÂû ÃÂð÷ÃÂðñþÃÂðý úðú ÃÂÃÂõôÃÂÃÂòþ ò÷ðøüþôõùÃÂÃÂòøàHTTP-ÃÂõÃÂòõÃÂð àÿÃÂþóÃÂðüüðüø, úþÃÂþÃÂÃÂõ üþóÃÂà÷ðÿÃÂÃÂúðÃÂÃÂÃÂàò þÿõÃÂðÃÂøþýýþù ÃÂøÃÂÃÂõüõ. ÃÂÃÂûø óþòþÃÂøÃÂàÃÂÿÃÂþÃÂõýýþ, ÃÂþ CGI, ÿõÃÂõôðòðàÃÂÿÃÂðòûõýøõ ÃÂðúþù ÿÃÂþóÃÂðüüõ (þñÃÂÃÂýþ øÃÂ
øüõýÃÂÃÂàcgi-ÃÂÃÂõýðÃÂøÃÂüø, ÃÂ
þÃÂàÃÂÃÂþ òÿþûýõ üþöõàñÃÂÃÂàø ôòþøÃÂýÃÂù ÃÂðùû, ÃÂð÷ÃÂðñþÃÂðýýÃÂù ýð C/C++), ÃÂþÃÂüøÃÂÃÂõàôûàýõõ þÿÃÂõôõûõýýþõ þúÃÂÃÂöõýøõ. àÃÂðÃÂÃÂýþÃÂÃÂø, ÿðÃÂðüõÃÂÃÂàHTTP-÷ðÿÃÂþÃÂð, ÿþûÃÂÃÂõýýþóþ þàúûøõýÃÂð, üþóÃÂàÿþüõÃÂðÃÂÃÂÃÂàò þÿÃÂõôõûõýýÃÂõ ÿõÃÂõüõýýÃÂõ þúÃÂÃÂöõýøàøûø ÿõÃÂõôðòðÃÂÃÂÃÂàcgi-ÿÃÂþóÃÂðüüõ úðú ðÃÂóÃÂüõýÃÂàøûø úðú òÃÂ
þôýþù ÿþÃÂþú (STDIN). àþÃÂòõàHTTP-ÃÂõÃÂòõàöôõàôðýýÃÂõ, úþÃÂþÃÂÃÂõ cgi-ÿÃÂþóÃÂðüüð ôþûöýð òÃÂôðÃÂàò ÃÂÃÂðýôðÃÂÃÂýÃÂù òÃÂÃÂ
þôýþù ÿþÃÂþú (STDOUT), ø ÿõÃÂõôðõàøÃÂ
úûøõýÃÂÃÂ. |
- | + | âðúøü þñÃÂð÷þü, òÃÂõ, ÃÂÃÂþ ÃÂÃÂõñÃÂõÃÂÃÂàþàcgi-ÿÃÂþóÃÂðüüÃÂ, ÃÂÃÂþ ÃÂÿþÃÂþñýþÃÂÃÂàÿþûÃÂÃÂðÃÂàýõþñÃÂ
þôøüÃÂàôûàÃÂðñþÃÂàøýÃÂþÃÂüðÃÂøàø÷ ÃÂþÃÂüøÃÂÃÂõüþù HTTP-ÃÂõÃÂòõÃÂþü ÃÂÃÂõôàø òþ÷òÃÂðÃÂðÃÂàþÃÂòõÃÂýÃÂõ ôðýýÃÂõ, ÃÂþþÃÂòõÃÂÃÂÃÂòÃÂÃÂÃÂøõ ÿÃÂþÃÂþúþûàHTTP, ÃÂÃÂþñàweb-úûøõýà÷ýðû, ÃÂÃÂþ àýøüø ôõûðÃÂÃÂ. | |
- | === | + | === ãÃÂøüÃÂàÿþÃÂÃÂûðÃÂà=== |
- | + | ÃÂðÃÂýõü àÃÂþÃÂüøÃÂþòðýøàHTTP-þÃÂòõÃÂð. çÃÂþñàñÃÂðÃÂ÷õàúûøõýÃÂð üþó õóþ ÿÃÂðòøûÃÂýþ þñÃÂðñþÃÂðÃÂÃÂ, þý ôþûöõý ÃÂþÃÂÃÂþÃÂÃÂàø÷ ÷ðóþûþòúð ø ÃÂõûð, ÃÂð÷ôõûõýýÃÂÃÂ
ÿÃÂÃÂÃÂþù ÃÂÃÂÃÂþúþù. à÷ðóþûþòúõ ÿõÃÂõôðõÃÂÃÂàýõþñÃÂ
þôøüðàÃÂûÃÂöõñýðàøýÃÂþÃÂüðÃÂøÃÂ, ýðÿÃÂøüõÃÂ, ÃÂøÿ ÃÂþôõÃÂöøüþóþ, õóþ úþôøÃÂþòúð, ÃÂúð÷ðýøõ ñÃÂðÃÂ÷õÃÂà÷ðÿÃÂþÃÂøÃÂàôÃÂÃÂóþù ÃÂõÃÂÃÂÃÂà(ÃÂðú ýð÷ÃÂòðõüþõ ÿõÃÂõýðÿÃÂðòûõýøõ), ø ÃÂ.ô. ÃÂÃÂþÃÂÃÂõùÃÂøù cgi-ÃÂÃÂõýðÃÂøù ýð ÃÂ÷ÃÂúõ Python üþöõàòÃÂóûÃÂôõÃÂàÃÂðú: | |
<source lang="python"> | <source lang="python"> | ||
Строка 66: | Строка 107: | ||
# -*- coding: utf-8 -*- | # -*- coding: utf-8 -*- | ||
print 'Content-Type: text/html\n' | print 'Content-Type: text/html\n' | ||
- | print '<H3> | + | print '<H3>ÃÂÃÂûø òàÃÂÃÂþ òøôøÃÂõ, ÷ýðÃÂøàòÃÂõ ÃÂðñþÃÂðõÃÂ</H3>' |
</source> | </source> | ||
- | + | ÃÂõÃÂòÃÂü þÿõÃÂðÃÂþÃÂþü print üàÃÂþÃÂüøÃÂÃÂõü üøýøüðûÃÂýþ ýõþñÃÂ
þôøüÃÂù ÷ðóþûþòþú â ñÃÂðÃÂ÷õàúûøõýÃÂð þñÃÂ÷ðÃÂõûÃÂýþ ôþûöõý ÷ýðÃÂÃÂ, úðúþò ÃÂøÿ ÿõÃÂõÃÂÃÂûðõüÃÂÃÂ
õüàôðýýÃÂÃÂ
(ò ýðÃÂõü ÃÂûÃÂÃÂðõ ÃÂÃÂþ ÿÃÂþÃÂÃÂþù ÃÂõúÃÂÃÂ, ÃÂþþÃÂòõÃÂÃÂÃÂòÃÂÃÂÃÂøù ÃÂþÃÂüðÃÂàHTML). ÃÂõ ÷ðñÃÂòðùÃÂõ þ ôþÿþûýøÃÂõûÃÂýþü ÿõÃÂõòþôõ ÃÂÃÂÃÂþúø \n, ýõþñÃÂ
þôøüþü ôûàþÃÂôõûõýøà÷ðóþûþòúð þàÃÂõûð þÃÂòõÃÂð. ÃÂàø ôðûõõ òàüþöõÃÂõ ÿõÃÂõôðòðÃÂàûÃÂñþù HTML-úþô. | |
- | + | ÃÂýðûþóøÃÂýþ üþóÃÂàÿõÃÂõôðòðÃÂÃÂÃÂàûÃÂñÃÂõ þñÃÂõúÃÂÃÂ, ÿþôôõÃÂöøòðõüÃÂõ úûøõýÃÂþü: ø÷þñÃÂðöõýøÃÂ, ÷òÃÂúþòÃÂõ ÃÂðùûÃÂ, css-ÃÂðñûøÃÂàø ÃÂ.ô. ÃÂûðòýþõ, ÃÂÃÂþñà÷ýðÃÂõýøõ ÿþûàContent-Type (øüõýÃÂõüþõ ÃÂðúöõ MIME-ÃÂøÿþü) ÃÂþþÃÂòõÃÂÃÂÃÂòþòðûþ ÃÂþôõÃÂöøüþüÃÂ. | |
- | === | + | === ÃÂôõÃÂàøóÃÂðÃÂÃÂ, ÷ôõÃÂàýõ øóÃÂðÃÂÃÂ... === |
- | + | ÃÂôýðúþ úðúþù ÃÂüÃÂÃÂû ÿþÃÂÃÂÃÂðÃÂàÃÂþÃÂüøÃÂþòðýøõ ÃÂÃÂðÃÂøÃÂõÃÂúøÃÂ
, ÿþ ÃÂÃÂÃÂø, ÃÂÃÂÃÂðýøàcgi-ÃÂÃÂõýðÃÂøÃÂ, õÃÂûø ÃÂðü HTTP-ÃÂõÃÂòõàÃÂÿÃÂðòøÃÂÃÂààÃÂÃÂøü ýðüýþóþ ûÃÂÃÂÃÂõ? àþñÃÂõü-ÃÂþ ýøúðúþóþ. àð÷òõ ÃÂÃÂþ ôûàþñÃÂõóþ ÃÂð÷òøÃÂøÃÂ... àòþàò ÃÂõü CGI ÿþ-ýðÃÂÃÂþÃÂÃÂõüàÃÂøûõý, ÃÂðú ÃÂÃÂþ ò ÃÂþÃÂüøÃÂþòðýøø ôøýðüøÃÂõÃÂúøÃÂ
ÃÂÃÂÃÂðýøÃÂ, ÃÂþôõÃÂöøüþõ úþÃÂþÃÂÃÂÃÂ
÷ðòøÃÂøàþàøýÃÂþÃÂüðÃÂøø, ÿõÃÂõôðýýþù ÿþûÃÂ÷þòðÃÂõûõü. | |
- | + | ÃÂÃÂþÃÂþúþû HTTP ÿÃÂõôÃÂÃÂüðÃÂÃÂøòðõàýõÃÂúþûÃÂúþ ÃÂÿþÃÂþñþò ÿõÃÂõôðÃÂø øýÃÂþÃÂüðÃÂøø þàúûøõýÃÂð ýð ÃÂõÃÂòõÃÂ, ýð÷ÃÂòðõüÃÂÃÂ
üõÃÂþôðüø. ÃÂðøñþûõõ ÿþÿÃÂûÃÂÃÂýÃÂõ ø÷ ýøÃÂ
â GET, POST, PUT ø HEAD. | |
- | + | ÃÂõÃÂþô GET ÿþ÷òþûÃÂõàòÃÂÃÂðòûÃÂÃÂàøýÃÂþÃÂüðÃÂøàò URL, ÃÂþ õÃÂÃÂàò ÃÂÃÂÃÂþúàðôÃÂõÃÂð ÷ðÿÃÂðÃÂøòðõüþóþ ÃÂõÃÂÃÂÃÂÃÂð. ÃÂþóôð ëïýôõúÃÂû òõÃÂýõàòðü ÃÂÿøÃÂþú øÃÂúþüÃÂÃÂ
ÃÂÃÂÃÂðýøÃÂ, ÿþÃÂüþÃÂÃÂøÃÂõ ýð ðôÃÂõÃÂýÃÂàÃÂÃÂÃÂþúàò ñÃÂðÃÂ÷õÃÂõ â òþàÃÂðú ôðýýÃÂõ ø ÿõÃÂõôðÃÂÃÂÃÂàüõÃÂþôþü GET. ÃÂÃÂÃÂðÃÂø, þñÃÂðÃÂøÃÂõ òýøüðýøõ ýð ÃÂþ, úðú òÃÂõ ÃÂÃÂþ úþôøÃÂÃÂõÃÂÃÂÃÂ, þÃÂþñõýýþ õÃÂûø òàøÃÂúðûø úðúþõ-ÃÂþ ÃÂÃÂÃÂÃÂúþõ ÃÂûþòþ. | |
- | + | ÃÂÃÂûø ýð ÃÂõÃÂòõàÃÂÃÂõñÃÂõÃÂÃÂàÿõÃÂõôðÃÂàñþûÃÂÃÂøù þñÃÂõü øýÃÂþÃÂüðÃÂøø, øûø õõ öõûðÃÂõûÃÂýþ ÃÂúÃÂÃÂÃÂàþàûÃÂñþÿÃÂÃÂýÃÂÃÂ
óûð÷, øÃÂÿþûÃÂ÷ÃÂõÃÂÃÂàôÃÂÃÂóþù üõÃÂþô â POST. àôðýýþü ÃÂûÃÂÃÂðõ ò ÷ðóþûþòúõ ÿõÃÂõôðõÃÂÃÂàûøÃÂàÃÂð÷üõàÿþûÃÂ÷þòðÃÂõûÃÂÃÂúøÃÂ
ôðýýÃÂÃÂ
, ð ÃÂðüø ôðýýÃÂõ ÿõÃÂõÃÂÃÂûðÃÂÃÂÃÂàò ÃÂõûõ ÷ðÿÃÂþÃÂð. | |
- | + | ÃÂõÃÂþô PUT ÿÃÂõôýð÷ýðÃÂðõÃÂÃÂàôûàÃÂð÷üõÃÂõýøàÃÂõÃÂÃÂÃÂÃÂþò ýð ÃÂõÃÂòõÃÂõ ø ÿþ ÃÂþþñÃÂðöõýøÃÂü ñõ÷þÿðÃÂýþÃÂÃÂø ÿÃÂðúÃÂøÃÂõÃÂúø ýõ øÃÂÿþûÃÂ÷ÃÂõÃÂÃÂÃÂ. ÃÂàø, ýðúþýõÃÂ, üõÃÂþô HEAD þÃÂõýàÿþÃÂ
þö ýð GET, ÷ð ÃÂõü øÃÂúûÃÂÃÂõýøõü, ÃÂÃÂþ ÃÂõÃÂòõàò þÃÂòõàýð ÃÂðúþù ÷ðÿÃÂþàòþ÷òÃÂðÃÂðõàýõ òõÃÂàÃÂõÃÂÃÂÃÂÃÂ, ð ûøÃÂàøýÃÂþÃÂüðÃÂøàþ ýõü, ÃÂðúÃÂàúðú ôðÃÂð ÿþÃÂûõôýõóþ ø÷üõýõýøÃÂ, ÿþüõÃÂðõüÃÂàò ÷ðóþûþòúõ. ÃÂñÃÂÃÂýþ øÃÂÿþûÃÂ÷ÃÂõÃÂÃÂàÿÃÂþúÃÂø-ÃÂõÃÂòõÃÂðüø ôûàþÿÃÂõôõûõýøàëÃÂòõöõÃÂÃÂøû øüõÃÂÃÂøÃÂ
ÃÂààýøÃÂ
ôðýýÃÂÃÂ
â ÃÂÃÂþøàûø ÷ðÿÃÂðÃÂøòðÃÂàÃÂõÃÂÃÂÃÂàÿþòÃÂþÃÂýþ øûø üþöýþ òõÃÂýÃÂÃÂàúûøõýÃÂàÃÂþ, ÃÂÃÂþ õÃÂÃÂàò úÃÂÃÂõ. | |
- | + | ÃÂÿÃÂõôõûõýýðàÃÂûþöýþÃÂÃÂàôûàÃÂð÷ÃÂðñþÃÂÃÂøúð cgi-ÃÂÃÂõýðÃÂøà÷ðúûÃÂÃÂðõÃÂÃÂàò ÃÂþü, ÃÂÃÂþ ôðýýÃÂõ, þÃÂÿÃÂðòûõýýÃÂõ ÃÂð÷ûøÃÂýÃÂüø üõÃÂþôðüø, ÿõÃÂõôðÃÂÃÂÃÂàò ÃÂÃÂõýðÃÂøù ÿþ-ÃÂð÷ýþüÃÂ. âðú, øýÃÂþÃÂüðÃÂøÃÂ, ÿþÃÂÃÂÃÂÿøòÃÂðààÿþüþÃÂÃÂàPOST, ÿþôðõÃÂÃÂàýð ÃÂÃÂðýôðÃÂÃÂýÃÂù òÃÂ
þô ÃÂÃÂõýðÃÂøàø üþöõàñÃÂÃÂàÃÂÃÂøÃÂðýð þÃÂÃÂÃÂôð, ýðÿÃÂøüõÃÂ, àÿþüþÃÂÃÂàsys.stdin.read(size) øûø ôðöõ ÃÂÃÂýúÃÂøõù raw_input() (ÃÂ
þÃÂàòþ òÃÂþÃÂþü ÃÂûÃÂÃÂðõ ÃÂûþöýõõ úþýÃÂÃÂþûøÃÂþòðÃÂàþñÃÂõü ÿÃÂøýøüðõüÃÂÃÂ
ôðýýÃÂÃÂ
). ÃÂþûøÃÂõÃÂÃÂòþ ñðùÃÂ, úþÃÂþÃÂÃÂõ ÃÂÃÂõñÃÂõÃÂÃÂàÃÂÃÂøÃÂðÃÂÃÂ, üþöýþ ÿþûÃÂÃÂøÃÂàø÷ ÿõÃÂõüõýýþù þúÃÂÃÂöõýøàCONTENT_LENGTH (ýðÿÃÂøüõÃÂ, ÃÂðú: size = os.environ['CONTENT_LENGTH']). | |
- | + | ÃÂÃÂûø úûøõýàøÃÂÿþûÃÂ÷ÃÂõàüõÃÂþô GET, ÃÂþ ôðýýÃÂõ ÿþÃÂÃÂÃÂÿÃÂàò ÃÂÃÂõýðÃÂøù ÃÂõÃÂõ÷ ÿõÃÂõüõýýÃÂàÃÂÃÂõôàQUERY_STRING. ÃÂõÃÂþô, úþÃÂþÃÂÃÂü ôðýýÃÂõ ÿõÃÂõôðýà(ýÃÂöýþ öõ úðú-ÃÂþ ÃÂð÷þñÃÂðÃÂÃÂÃÂÃÂ, óôõ øÃÂ
øÃÂúðÃÂÃÂ) üþöýþ òÃÂõóôð ÿþûÃÂÃÂøÃÂàø÷ REQUEST_METHOD. | |
- | + | ÃÂÃÂÃÂàõÃÂõ þôøý þÃÂþñÃÂù ÃÂûÃÂÃÂðù. ÃÂÃÂûø ôðýýÃÂõ ÿõÃÂõôðÃÂÃÂÃÂàüõÃÂþôþü GET, ýþ àøÃÂÿþûÃÂ÷þòðýøõü ëøýôõúÃÂýþóþû ÃÂþÃÂüðÃÂð, úþÃÂþÃÂÃÂù ÃÂþÃÂüøÃÂÃÂõÃÂÃÂàÃÂõóþü <ISINDEX>, ÃÂþ ò ÃÂÃÂþü ÃÂûÃÂÃÂðõ þýø úþôøÃÂÃÂÃÂÃÂÃÂàýõ ò òøôõ ëÿõÃÂõüõýýðÃÂ=÷ýðÃÂõýøõ&ÿõÃÂõüõýýðÃÂ=÷ýðÃÂõýøõ&...û, ð úðú ë÷ýðÃÂõýøõ+÷ýðÃÂõýøõ+...û. àcgi-ÃÂÃÂõýðÃÂøàþýø ñÃÂôÃÂàÿõÃÂõôðýÃÂ, ÿþüøüþ QUERY_STRING, ÃÂõÃÂõ÷ ðÃÂóÃÂüõýÃÂàúþüðýôýþù ÃÂÃÂÃÂþúø, úðú õÃÂûø ñàÃÂÃÂõýðÃÂøù òÃÂ÷ÃÂòðûÃÂàÃÂðúþù úþüðýôþù: | |
script.cgi arg1 arg2 arg3 | script.cgi arg1 arg2 arg3 | ||
- | + | âþ õÃÂÃÂÃÂ, ýð ÃÂÃÂþàÃÂð÷ ÿþûÃÂ÷þòðÃÂõûÃÂÃÂúøõ ôðýýÃÂõ üþöýþ ñÃÂôõàÿþûÃÂÃÂøÃÂàúðú sys.argv[1] ø ÃÂ.ô. | |
- | + | ÃÂðú òøôøÃÂõ, þóÃÂþüýþõ ÃÂøÃÂûþ òðÃÂøðýÃÂþò, ÿÃÂõôÃÂÃÂüþÃÂÃÂõýýÃÂÃÂ
CGI-øýÃÂõÃÂÃÂõùÃÂþü, úþÃÂþÃÂÃÂõ òÃÂõ ôþûöýàñÃÂÃÂàÃÂÃÂÃÂõýàÿÃÂø ÃÂð÷ÃÂðñþÃÂúõ ÃÂÃÂõýðÃÂøÃÂ, üþöõàòÃÂ÷òðÃÂàýõÃÂòýÃÂù ÃÂøú ôðöõ àþÿÃÂÃÂýÃÂÃÂ
ÿÃÂþóÃÂðüüøÃÂÃÂþò, úþÃÂþÃÂÃÂõ ø òþ ÃÂýõ ÿþÃÂøÃÂ
þýÃÂúàýðñøòðÃÂàÿþ ÿþôÃÂÃÂúõ úðúþù-ÃÂþ úþô. àõÃÂûø õÃÂõ òÃÂÿþüýøÃÂÃÂ, ÃÂÃÂþ ôðýýÃÂõ ÿõÃÂõôðÃÂÃÂÃÂàò ÷ðúþôøÃÂþòðýýþü òøôõ (ÃÂÃÂþ ðýóûøÃÂðýðü ÃÂ
þÃÂþÃÂþ â ò÷ÃÂû ÷ýðÃÂõýøõ ÿõÃÂõüõýýþù ø ÃÂðñþÃÂðù, ð ýðü-ÃÂþ àòðüø ÃÂÃÂþ ÷ýðÃÂõýøõ òõÃÂýõÃÂÃÂàò òøôõ %EC%E4%E0), ôð õÃÂõ ø þ ÿÃÂþòõÃÂúõ ÃÂÃÂøÃÂ
ôðýýÃÂÃÂ
ýÃÂöýþ ÿþ÷ðñþÃÂøÃÂÃÂÃÂÃÂ, ÃÂÃÂþñàúðúþù-ýøñÃÂôàýðÃÂøýðÃÂÃÂøù ÃÂ
ðúõàýõ ÿþÿÃÂÃÂðûÃÂà÷ðÃÂÃÂðòøÃÂàýðàÃÂõÃÂòõàÃÂðñþÃÂðÃÂàÿþ-ÃÂòþõüÃÂ... ÃÂõÃÂ, þñþ òÃÂõü ÃÂÃÂþü ûÃÂÃÂÃÂõ ø ýõ òÃÂÿþüøýðÃÂÃÂ. ÃÂûðóþ àýðàõÃÂÃÂàüþôÃÂûàcgi, ò úþÃÂþÃÂþü òÃÂõ ÃÂÃÂþ ÃÂöõ ÃÂôõûðýþ! | |
- | + | ÃÂþ þ ýõü â ÃÂÃÂÃÂàÿþ÷öõ. áýðÃÂðûð ÿðÃÂàÃÂûþò ýÃÂöýþ ÃÂúð÷ðÃÂàþ HTML-ÃÂþÃÂüðÃÂ
. | |
- | === | + | === äþÃÂüøÃÂÃÂõü ÃÂþÃÂüà=== |
- | + | çÃÂþñàòðü ñÃÂûþ ÿÃÂþÃÂõ ÿþýÃÂÃÂàÃÂðÃÂÃÂüðÃÂÃÂøòðõüÃÂù ÃÂõóþôýàÿÃÂøüõÃÂ, úþÃÂþÃÂúþ ÃÂúðöàÿÃÂþ ÃÂþ, úðú öõ úûøõýàòÃÂÿþûýÃÂõàÿõÃÂõôðÃÂàôðýýÃÂÃÂ
ýðÃÂõüàcgi-ÃÂÃÂõýðÃÂøÃÂ. ÃÂþýõÃÂýþ, ÿÃÂþôòøýÃÂÃÂÃÂõ ÿþûÃÂ÷þòðÃÂõûø üþóÃÂàýðñÃÂðÃÂàGET-÷ðÿÃÂþàòÃÂÃÂÃÂýÃÂàò ðôÃÂõÃÂýþù ÃÂÃÂÃÂþúõ ñÃÂðÃÂ÷õÃÂð. Ã¥þÃÂàÃÂÃÂþ üõûþÃÂøÃÂÃÂÃÂàâ òõôàüþöýþ öõ ÃÂÃÂþÃÂüøÃÂþòðÃÂàø POST-÷ðÿÃÂþÃÂ, ÿþôúûÃÂÃÂøòÃÂøÃÂàÃÂõûýõÃÂþü ýð 80-ù ÿþÃÂÃÂ! ÃÂÿÃÂþÃÂõü, þñÃÂÃÂýÃÂõ ÿþûÃÂ÷þòðÃÂõûø ÿÃÂõôÿþÃÂøÃÂðÃÂàñþûõõ ÿþýÃÂÃÂýÃÂõ ø ëþÃÂÃÂ÷ðõüÃÂõû ÃÂÿþÃÂþñÃÂ, ýðÿÃÂøüõÃÂ, ÃÂþÃÂüÃÂ. | |
- | + | ÃÂðú þýø òÃÂóûÃÂôÃÂÃÂ, ôÃÂüðÃÂ, úðöôÃÂù ÷ýðõÃÂ. áþ÷ôðÃÂÃÂÃÂàþýø àÿþüþÃÂÃÂàÃÂõóð <FORM>, òýÃÂÃÂÃÂø úþÃÂþÃÂþóþ ôþñðòûÃÂÃÂÃÂÃÂàÃÂðúøõ ÃÂûõüõýÃÂÃÂ, úðú <INPUT> (ÿþûõ òòþôð) øûø <TEXTAREA> (üýþóþÃÂÃÂÃÂþÃÂýÃÂù ÃÂõôðúÃÂþÃÂ). ÃÂÃÂøü ÃÂûõüõýÃÂðü, õÃÂûø øÃÂ
ôðýýÃÂõ ôþûöýàñÃÂÃÂàÿõÃÂõôðýàýð ÃÂõÃÂòõÃÂ, ÿÃÂøÃÂòðøòðÃÂÃÂÃÂàøüõýð àÿþüþÃÂÃÂàðÃÂÃÂøñÃÂÃÂð name. ÃÂðÃÂðûÃÂýþõ ÷ýðÃÂõýøõ ÷ðôðõÃÂÃÂàÿðÃÂðüõÃÂÃÂþü value ø ò ôðûÃÂýõùÃÂõü ôûàëÃÂõôðúÃÂøÃÂÃÂõüÃÂÃÂ
û ÿþûõù üþöõàñÃÂÃÂàø÷üõýõýþ ÿþûÃÂ÷þòðÃÂõûõü. ÃÂþóôð ÿþûÃÂ÷þòðÃÂõûàýðöøüðõàúýþÿúàëÃÂÃÂÿÃÂðòøÃÂÃÂû (ýðôÿøÃÂàýð ýõù, ò ÿÃÂøýÃÂøÿõ, üþöýþ ø÷üõýøÃÂÃÂ), ÃÂþ ñÃÂðÃÂ÷õàþñÃÂõôøýÃÂõàòÃÂõ ôðýýÃÂõ ÿþûõù ò ÿðÃÂàname=value, ÃÂð÷ôõûÃÂàøÃÂ
ÃÂøüòþûþü &. ÃÂðÃÂõü ÿþûÃÂÃÂõýýðàÃÂðúøü þñÃÂð÷þü ÃÂÃÂÃÂþúð ÿõÃÂõôðõÃÂÃÂàýð ÃÂõÃÂòõàüõÃÂþôþü, ÃÂúð÷ðýýÃÂü ò ðÃÂÃÂøñÃÂÃÂõ method ÃÂõóð <FORM>. ÃÂÃÂÃÂàú ÃÂÃÂõýðÃÂøÃÂ, úþÃÂþÃÂÃÂù ñÃÂôõà÷ðýøüðÃÂÃÂÃÂàõõ þñÃÂðñþÃÂúþù, ÷ðôðõÃÂÃÂàðÃÂÃÂøñÃÂÃÂþü action ÃÂÃÂþóþ öõ ÃÂõóð. ÃÂÃÂûø action ýõ ÷ðôðý, ÃÂþ ôðýýÃÂõ ÿõÃÂõôðÃÂÃÂÃÂàÃÂðùûÃÂ, ÃÂÃÂþÃÂüøÃÂþòðòÃÂõüàÃÂõúÃÂÃÂÃÂàÃÂÃÂÃÂðýøÃÂúÃÂ. | |
- | + | ÃÂÃÂûø ÃÂÃÂþ-ÃÂþ ýõ ÃÂþòÃÂõü ÿþýÃÂÃÂýþ, þñÃÂðÃÂøÃÂõÃÂàú úþôàÃÂð÷ÃÂðñðÃÂÃÂòðõüþù óþÃÂÃÂõòþù úýøóø, úþÃÂþÃÂÃÂù ÿÃÂøòõôõý ýøöõ. | |
- | === | + | === ÃÂðàÃÂÿðÃÂøÃÂõûàâ üþôÃÂûàcgi === |
- | + | ÃÂþ÷òÃÂðÃÂðõüÃÂàú þñÃÂðñþÃÂúõ òÃÂõóþ ÃÂÃÂþóþ ôþñÃÂð, úþÃÂþÃÂþõ ÃÂþÃÂýø ÿþûÃÂ÷þòðÃÂõûõù ÃÂöõ óþÃÂþòàþñÃÂÃÂÃÂøÃÂàýð ýðàñõôýÃÂù ÃÂÃÂõýðÃÂøù. ÃÂàÃÂõÃÂøûø òþÃÂÿþûÃÂ÷þòðÃÂÃÂÃÂàÃÂÃÂðýôðÃÂÃÂýÃÂüø ÃÂÃÂõôÃÂÃÂòðüø Python, ø ÷ôõÃÂàòÃÂõ ôõùÃÂÃÂòøÃÂõûÃÂýþ þÃÂõýàÿÃÂþÃÂÃÂþ â øüÿþÃÂÃÂøÃÂÃÂùÃÂõ üþôÃÂûàcgi ø, ÃÂþ÷ôðò þñÃÂõúàúûðÃÂÃÂð FieldStorage, òàÿþûÃÂÃÂøÃÂõ ÃÂõÃÂõ÷ ýõóþ ôþÃÂÃÂÃÂÿ úþ òÃÂõü ôðýýÃÂü, ÿõÃÂõôðýýÃÂü ÿþûÃÂ÷þòðÃÂõûõü, ýõ÷ðòøÃÂøüþ þàøÃÂÿþûÃÂ÷ÃÂõüþóþ üõÃÂþôð: | |
<source lang="python"> | <source lang="python"> | ||
Строка 112: | Строка 153: | ||
data = cgi.FieldStorage() | data = cgi.FieldStorage() | ||
for entry in data.keys(): | for entry in data.keys(): | ||
- | print ' | + | print 'ÃÂõÃÂõüõýýðà%s øüõõà÷ýðÃÂõýøõ %s' % (entry, data[entry].value) |
</source> | </source> | ||
- | + | ÃÂÃÂûø òðü ýÃÂöýþ ÿþûÃÂÃÂøÃÂà÷ýðÃÂõýøõ þÿÃÂõôõûõýýþóþ ÿþûÃÂ, ÃÂÃÂþ ôõûðõÃÂÃÂàÃÂðú: | |
<source lang="python"> | <source lang="python"> | ||
Строка 121: | Строка 162: | ||
</source> | </source> | ||
- | + | ÃÂþüøüþ ÿþûÃÂ÷þòðÃÂõûÃÂÃÂúøÃÂ
ôðýýÃÂÃÂ
, þñÃÂõúàúûðÃÂÃÂð FieldStorage ÃÂþôõÃÂöøàøýÃÂþÃÂüðÃÂøàø þ ÿþûÃÂÃÂ
÷ðóþûþòúð (ò ýðÃÂõü ÿÃÂøüõÃÂõ øÃÂ
üþöýþ ÿþûÃÂÃÂøÃÂàø÷ ÃÂûþòðÃÂàdata.headers). MIME-ÃÂøÿ ôðýýÃÂÃÂ
(ÿõÃÂõôðòðõüÃÂù ÿþûõü ÷ðóþûþòúð Content-Type) üþöýþ ÿþûÃÂÃÂøÃÂàø÷ ðÃÂÃÂøñÃÂÃÂð data.type. çõÃÂõ÷ ÃÂÃÂþàöõ þñÃÂõúàüþöõàñÃÂÃÂàòÃÂÿþûýõýð ø ÷ðóÃÂÃÂ÷úð ÃÂðùûð. | |
- | + | á ÿþüþÃÂÃÂàüõÃÂþôþò keys() ø has_key() üþöýþ òÃÂÿþûýÃÂÃÂàþñÃÂðñþÃÂúàÿþûÃÂÃÂõýýÃÂÃÂ
ôðýýÃÂÃÂ
ò ÃÂøúûõ ø ÿÃÂþòõÃÂÃÂÃÂàýðûøÃÂøõ ÃÂþù øûø øýþù ÿõÃÂõüõýýþù. ÃÂÃÂÃÂðÃÂø óþòþÃÂÃÂ, ÿÃÂþòõÃÂÃÂÃÂàýðûøÃÂøõ ÿõÃÂõüõýýþù òþ òÃÂ
þôýÃÂÃÂ
ôðýýÃÂÃÂ
, ÿÃÂõöôõ ÃÂõü ÿÃÂøÃÂÃÂÃÂÿðÃÂàú øÃÂ
þñÃÂðñþÃÂúõ, ýÃÂöýþ ýõÿÃÂõüõýýþ â òõôà÷ðÿÃÂþàÃÂþÃÂüøÃÂÃÂõÃÂÃÂàúûøõýÃÂþü, ð úÃÂþ ÷ýðõÃÂ, ÃÂÃÂþ àýõóþ ýð ÃÂüõ? | |
- | === | + | === ÃÂð÷øÃÂÃÂõü ôðýýÃÂõ === |
- | + | ÃÂÃÂðú, ÿþûÃÂÃÂðÃÂàôðýýÃÂõ þàúûøõýÃÂð üàýðÃÂÃÂøûøÃÂÃÂ. ÃÂÃÂÿÃÂðòûÃÂÃÂàÃÂþöõ ÃÂüõõü. ÃÂÃÂÃÂðûþÃÂàÿÃÂøôÃÂüðÃÂÃÂ, úðú ÃÂÃÂø ôðýýÃÂõ ûÃÂÃÂÃÂõ òÃÂõóþ ÃÂ
ÃÂðýøÃÂÃÂ. ÃÂþýõÃÂýþ, ôûàýõÃÂûþöýþù óþÃÂÃÂõòþù úýøóø àýõñþûÃÂÃÂþù ýðóÃÂÃÂ÷úþù òÿþûýõ ÃÂ
òðÃÂøûþ ñàø ÃÂõúÃÂÃÂþòÃÂÃÂ
ÃÂðùûþò. ÃÂÃÂðòôð, ÃÂðü õÃÂÃÂàÃÂòþø ÃÂûþöýþÃÂÃÂø â õÃÂûø ÃÂÃÂð÷àÿÃÂÃÂàÃÂõûþòõú ÷ðÃÂ
þÃÂÃÂàòÃÂÃÂúð÷ðÃÂàÃÂòþõ üýõýøõ þ òðÃÂõù úÃÂÃÂÃÂõùÃÂõù ôþüðÃÂýõù ÃÂÃÂÃÂðýøÃÂúõ, ÃÂþ ÃÂÃÂõýðÃÂøàÿÃÂøôõÃÂÃÂàúðúøü-ÃÂþ þñÃÂð÷þü ÃÂõóÃÂûøÃÂþòðÃÂàôþÃÂÃÂÃÂÿ ú ÃÂðùûÃÂ-ÃÂ
ÃÂðýøûøÃÂà(úðú üøýøüÃÂü, þñÃÂðñðÃÂÃÂòðÃÂàÃÂøÃÂÃÂðÃÂøÃÂ, õÃÂûø ÃÂðùû ÃÂöõ þÃÂúÃÂÃÂàýð ÷ðÿøÃÂàôÃÂÃÂóøü ÃÂú÷õüÿûÃÂÃÂþü ÃÂÃÂõýðÃÂøÃÂ). ÃÂþ ÷ðÃÂõü ýðü òÃÂõ ÃÂÃÂø óþûþòýÃÂõ ñþûø? ÃÂÃÂûø üàÃÂðú ûþòúþ þÃÂòõÃÂÃÂõûøÃÂàþàýõþñÃÂ
þôøüþÃÂÃÂø òÃÂÃÂÃÂýÃÂàÃÂð÷ñøÃÂðÃÂàHTTP-÷ðÿÃÂþÃÂÃÂ, ÃÂþ ýõÃÂöõûø ýõ ýðùôõü ÃÂÃÂþ-ÃÂþ ÿþôÃÂ
þôÃÂÃÂõõ ýð ÃÂÃÂþàÃÂð÷? | |
- | + | ÃÂþýõÃÂýþ, ýðùôõü! àÃÂÃÂþ ëÃÂÃÂþ-ÃÂþû ýð÷ÃÂòðõÃÂÃÂàÃÂøÃÂÃÂõüþù ÃÂÿÃÂðòûõýøàñð÷ðüø ôðýýÃÂÃÂ
(ò ÿÃÂþÃÂÃÂþÃÂõÃÂÃÂõ â áãÃÂÃÂ). âõÿõÃÂàýðÃÂõ ôõûþ â þÃÂÿÃÂðòøÃÂà÷ðÿÃÂþàø ÿþûÃÂÃÂøÃÂàþÃÂòõÃÂ. ÃÂÃÂõ þÃÂÃÂðûÃÂýþõ â ÃÂöõ ýõ ýðÃÂð ÷ðñþÃÂð. | |
- | + | ÃÂûàÃÂÃÂþóþ ÿÃÂøüõÃÂð àòÃÂñÃÂðû ò úðÃÂõÃÂÃÂòõ ëþÃÂòõÃÂÃÂÃÂòõýýþóþû ÷ð ÃÂ
ÃÂðýõýøõ ôðýýÃÂÃÂ
ÃÂõÃÂòõàñð÷ ôðýýÃÂÃÂ
PostgreSQL. ÃÂþÃÂúþûÃÂúàüàÿøÃÂõü ýàþÃÂõýàÿÃÂþÃÂÃÂÃÂàóþÃÂÃÂõòÃÂàúýøóÃÂ, ÃÂþ ø ÃÂÃÂÃÂÃÂúÃÂÃÂÃÂð ñð÷àñÃÂôõààýðàÃÂûõüõýÃÂðÃÂýþù â þôýð ÃÂðñûøÃÂð àÃÂÃÂõüàÿþûÃÂüø: òÃÂõüàÿÃÂñûøúðÃÂøø ÃÂþþñÃÂõýøÃÂ, øüàðòÃÂþÃÂð ø, ÃÂþñÃÂÃÂòõýýþ, ÃÂðüþ ÃÂþþñÃÂõýøõ: | |
admin@toshiba:~$ psql | admin@toshiba:~$ psql | ||
Строка 139: | Строка 180: | ||
CREATE DATABASE | CREATE DATABASE | ||
admin=# \connect guestbook | admin=# \connect guestbook | ||
- | + | ÃÂàÿþôÃÂþõôøýøûøÃÂàú ñð÷õ ôðýýÃÂÃÂ
"guestbook". | |
guestbook=# create table guestbook ( | guestbook=# create table guestbook ( | ||
guestbook(# datum timestamp, author varchar, message varchar); | guestbook(# datum timestamp, author varchar, message varchar); | ||
Строка 148: | Строка 189: | ||
admin@toshiba:~$ | admin@toshiba:~$ | ||
- | + | ÃÂþöðûÃÂù, õôøýÃÂÃÂòõýýþõ, ÃÂÃÂþ ÷ôõÃÂàýÃÂöýþ ÿþÃÂÃÂýøÃÂÃÂ, ÃÂÃÂþ ÿþÃÂõüàñð÷õ ø ÃÂðñûøÃÂõ üàýð÷ýðÃÂøûø òûðôõûÃÂÃÂõü ÿþûÃÂ÷þòðÃÂõûàwww-data. ÃÂÃÂþÃÂÃÂþ ú ýøü ñÃÂôõàþñÃÂðÃÂðÃÂÃÂÃÂàcgi-ÃÂÃÂõýðÃÂøù, ÃÂðñþÃÂðÃÂÃÂøù àÿÃÂðòðüø HTTP-ÃÂõÃÂòõÃÂð Apache, úþÃÂþÃÂÃÂù, ò ÃÂòþàþÃÂõÃÂõôÃÂ, øÃÂÿþûýÃÂõÃÂÃÂàþàøüõýø ôðýýþóþ ÿþûÃÂ÷þòðÃÂõûà[ò òðÃÂõü ôøÃÂÃÂÃÂøñÃÂÃÂøòõ þý üþöõàýð÷òðÃÂÃÂÃÂàÿþ-ôÃÂÃÂóþüÃÂ, â ÿÃÂøü. ÃÂõô.]. àPostgreSQL ÿþ ÃÂüþûÃÂðýøàÃÂÃÂõñÃÂõÃÂ, ÃÂÃÂþñàøüàÿþûÃÂ÷þòðÃÂõûàò ÃÂàÃÂþòÿðôðûþ àõóþ ÃÂøÃÂÃÂõüýÃÂü øüõýõü. ÃÂýõ ÃÂÃÂþ úðöõÃÂÃÂàôþÃÂÃÂðÃÂþÃÂýþ ÃÂôþñýÃÂü, ÃÂ
þÃÂàòÃÂ, úþýõÃÂýþ, üþöõÃÂõ ÿþÃÂÃÂÃÂÿøÃÂàÿþ-ÃÂòþõüÃÂ. | |
- | === DB API | + | === DB API ýð ÃÂÃÂÃÂðöõ ÃÂýøÃÂøúðÃÂøø === |
- | + | ÃÂÃÂÃÂðûþÃÂàÃÂð÷þñÃÂðÃÂÃÂÃÂÃÂ, úðú öõ Python ò÷ðøüþôõùÃÂÃÂòÃÂõààñð÷ðüø ôðýýÃÂÃÂ
. ÃÂûàÃÂÃÂþóþ Python ÿÃÂõôþÃÂÃÂðòûÃÂõàDB API â ÃÂÿõÃÂøðûÃÂýÃÂù øýÃÂõÃÂÃÂõùÃÂ, ÃÂýøÃÂøÃÂøÃÂÃÂÃÂÃÂøù ýðñþàüõÃÂþôþò, úþÃÂþÃÂÃÂõ ñÃÂôÃÂàþôøýðúþòþ ÃÂðñþÃÂðÃÂàýõ÷ðòøÃÂøüþ þàÃÂþóþ, àúðúþù áãÃÂàüàò÷ðøüþôõùÃÂÃÂòÃÂõü. ÃÂûàÃÂðñþÃÂààPostgreSQL ýðü ÿþýðôþñøÃÂÃÂàüþôÃÂûàPyPgSQL (ò ÃÂÃÂðýôðÃÂÃÂýþù ÿþÃÂÃÂðòúõ õóþ üþöõàýõ þúð÷ðÃÂÃÂÃÂÃÂ, ýþ òðàüõýõôöõàÿðúõÃÂþò ýðòõÃÂýÃÂúð ñÃÂôõàò úÃÂÃÂÃÂõ, úðú õóþ ÃÂÃÂÃÂðýþòøÃÂÃÂ; úÃÂÃÂðÃÂø, ÃÂÃÂþ ýõ õôøýÃÂÃÂòõýýÃÂù üþôÃÂûàâ àòðÃÂ, òþ÷üþöýþ, ñÃÂôõàPyGreSQL, úþÃÂþÃÂÃÂù ÃÂðñþÃÂðõàýøÃÂÃÂÃÂàýø ÃÂ
ÃÂöõ ø àÃÂõüø öõ ÃÂðüÃÂüø üõÃÂþôðüø). | |
- | DB API | + | DB API þÿÃÂõôõûÃÂõàÃÂÃÂðýôðÃÂÃÂýÃÂõ üõÃÂþôàÃÂðñþÃÂààñð÷ðüø ôðýýÃÂÃÂ
, ÃÂðú ÃÂÃÂþ, úðúþù ñàüþôÃÂûàòàýø ÷ðóÃÂÃÂ÷øûø ø àúðúþù ñàáãÃÂàýø ÃÂðñþÃÂðûø (ñÃÂôàÃÂþ MySQL, PostgreSQL, SQLite øûø ÃÂÃÂþ-ÃÂþ õÃÂõ), üõýÃÂÃÂÃÂÃÂàñÃÂôõàÃÂþûÃÂúþ øüàüþôÃÂûÃÂ. ÃÂûðòýþõ, ÃÂÃÂþñàøÃÂÿþûÃÂ÷ÃÂõüÃÂù üþôÃÂûàÃÂþþÃÂòõÃÂÃÂÃÂòþòðû DB API. àðÃÂÃÂüþÃÂÃÂøü úþÃÂþÃÂúþ þÃÂýþòýÃÂõ üõÃÂþôÃÂ: |
<source lang="python"> | <source lang="python"> | ||
Строка 159: | Строка 200: | ||
</source> | </source> | ||
- | + | âðú þÃÂÃÂÃÂõÃÂÃÂòûÃÂõÃÂÃÂàÿþôúûÃÂÃÂõýøõ ú ñð÷õ. à÷ðòøÃÂøüþÃÂÃÂø þàÃÂøÃÂÃÂðÃÂøø, òðü üþöõàÿþÃÂÃÂõñþòðÃÂÃÂÃÂàÃÂúð÷ðÃÂàÃÂþûÃÂúþ ýÃÂöýÃÂõ ÿðÃÂðüõÃÂÃÂà(ýðÿÃÂøüõÃÂ, øüàÃÂ
þÃÂÃÂð 'localhost' ÿþôÃÂð÷ÃÂüõòðõÃÂÃÂàÿþ ÃÂüþûÃÂðýøÃÂ). | |
<source lang="python"> | <source lang="python"> | ||
Строка 165: | Строка 206: | ||
</source> | </source> | ||
- | + | ÃÂÃÂÃÂÃÂþÃÂàÿþôôõÃÂöøòðÃÂÃÂÃÂàôðûõúþ ýõ òÃÂõüø áãÃÂÃÂ, ýþ ôûàþñÃÂýþÃÂÃÂø ò DB API þýø òòõôõýàø, ò ÃÂûÃÂÃÂðõ ýõþñÃÂ
þôøüþÃÂÃÂø, ôþûöýàÃÂüÃÂûøÃÂþòðÃÂÃÂÃÂàüþôÃÂûÃÂüø ÃÂþÿÃÂÃÂöõýøàøÃÂúÃÂÃÂÃÂÃÂòõýýþ. âðú ÃÂÃÂþ ýõ ÷ðñÃÂòðùÃÂõ þÃÂÿÃÂðòûÃÂÃÂàòÃÂõ òðÃÂø ÷ðÿÃÂþÃÂàÃÂõÃÂõ÷ úÃÂÃÂÃÂþÃÂ. | |
<source lang="python"> | <source lang="python"> | ||
Строка 171: | Строка 212: | ||
</source> | </source> | ||
- | + | âðú òÃÂÿþûýÃÂõÃÂÃÂàSQL-÷ðÿÃÂþÃÂ. ÃÂÃÂûø ò ÃÂÃÂÃÂþúõ ÷ðÿÃÂþÃÂð øÃÂÿþûÃÂ÷ÃÂÃÂÃÂÃÂà÷ýðúþüõÃÂÃÂð %s, ÃÂþ òÃÂþÃÂÃÂü ÿðÃÂðüõÃÂÃÂþü ÿõÃÂõôðõÃÂÃÂàÃÂÿøÃÂþú ÿõÃÂõüõýýÃÂÃÂ
-÷ýðÃÂõýøù, ÿÃÂøÃÂõü ò SQL-÷ðÿÃÂþÃÂõ ÷ýðúþüõÃÂÃÂð ýõ ÃÂÃÂõñÃÂõÃÂÃÂàþúÃÂÃÂöðÃÂàðÿþÃÂÃÂÃÂþÃÂðüø â üþôÃÂûàÃÂôõûðõàÃÂÃÂþ ÃÂðüþÃÂÃÂþÃÂÃÂõûÃÂýþ ò ÷ðòøÃÂøüþÃÂÃÂø þà| |
- | + | ÃÂøÿð ÿõÃÂõüõýýþù. | |
<source lang="python"> | <source lang="python"> | ||
Строка 178: | Строка 219: | ||
</source> | </source> | ||
- | + | ÃÂþ÷òÃÂðÃÂðõàôòÃÂüõÃÂýÃÂù ÃÂÿøÃÂþú (ÃÂÃÂÃÂþúø â ÿþûÃÂ) ÿþûÃÂÃÂõýýÃÂÃÂ
þàáãÃÂàôðýýÃÂÃÂ
. áÃÂÃÂõÃÂÃÂòÃÂÃÂàø ôÃÂÃÂóøõ üõÃÂþôÃÂ, þ÷ýðúþüøÃÂÃÂÃÂààúþÃÂþÃÂÃÂüø òàÃÂüþöõÃÂõ ò ôþúÃÂüõýÃÂðÃÂøø øûø àÿþüþÃÂÃÂà÷ýðúþüþù òðü ÃÂÃÂýúÃÂøø dir() ôð ÿðÃÂÃÂ-ÃÂÃÂþùúø ýõÃÂûþöýÃÂÃÂ
ÃÂúÃÂÿõÃÂøüõýÃÂþò. | |
- | === | + | === ÃÂðúÃÂõÿûÃÂõü ýð ÿÃÂðúÃÂøúõ === |
- | + | ÃÂõÃÂõùôõü ú ÃÂðÃÂÃÂüþÃÂÃÂõýøàýðÃÂõóþ ÿÃÂøüõÃÂð. ÃÂðÃÂýõü ÃÂÃÂðýôðÃÂÃÂýþ â ÃÂúðöõü úþôøÃÂþòúÃÂ, ÿþôúûÃÂÃÂøü ýÃÂöýÃÂõ üþôÃÂûø: | |
<source lang="python"> | <source lang="python"> | ||
Строка 190: | Строка 231: | ||
</source> | </source> | ||
- | + | ÃÂðûõõ, þÿÃÂõôõûøü ôòõ ÃÂÃÂýúÃÂøø. ÃÂõÃÂòðàñÃÂôõàþÃÂòõÃÂðÃÂà÷ð ôþñðòûõýøõ ýþòþóþ ÃÂþþñÃÂõýøàò ñð÷ÃÂ: | |
<source lang="python"> | <source lang="python"> | ||
Строка 204: | Строка 245: | ||
</source> | </source> | ||
- | + | ÃÂðú òøôøÃÂõ, òÃÂõ þÃÂõýàôðöõ ûþóøÃÂýþ: ÃÂÃÂÃÂðýðòûøòðõü ÃÂþõôøýõýøõ àÃÂà(ÿþÃÂúþûÃÂúàò ýðÃÂõü ÃÂûÃÂÃÂðõ ÿþôúûÃÂÃÂõýøõ òÃÂÿþûýÃÂõÃÂÃÂààøüõýõü ÃÂõúÃÂÃÂõóþ ÃÂøÃÂÃÂõüýþóþ ÿþûÃÂ÷þòðÃÂõûÃÂ, ÃÂþ ôþÃÂÃÂðÃÂþÃÂýþ ÃÂúð÷ðÃÂàÃÂþûÃÂúþ øüàñð÷ÃÂ), ÃÂþ÷ôðõü úÃÂÃÂÃÂþà(ò PostgreSQL þýø ýõ ÿÃÂøüõýÃÂÃÂÃÂÃÂÃÂ, ýþ þýø ÃÂüÃÂûøÃÂÃÂÃÂÃÂÃÂàúðöôÃÂü üþôÃÂûõü, ÿÃÂõÃÂõýôÃÂÃÂÃÂøü ýð ÃÂþþÃÂòõÃÂÃÂÃÂòøõ DB API), òÃÂÿþûýÃÂõÃÂÃÂà÷ðÿÃÂþÃÂ, ÷ðúÃÂÃÂòðõÃÂÃÂàúÃÂÃÂÃÂþÃÂ, ÃÂøúÃÂøÃÂÃÂÃÂÃÂÃÂàø÷üõýõýøà(PostgreSQL øÃÂÿþûÃÂ÷ÃÂõàÃÂÃÂðý÷ðúÃÂøø, ÿþÃÂÃÂþüàòÃÂÿþûýõýøõ üõÃÂþôð commit() þñÃÂ÷ðÃÂõûÃÂýþ, øýðÃÂõ òðÃÂø ø÷üõýõýøàýõ ñÃÂôÃÂàÃÂþÃÂ
ÃÂðýõýÃÂ), ø, ýðúþýõÃÂ, ÷ðúÃÂÃÂòðõü ÃÂðüþ ÃÂþõôøýõýøõ àñð÷þù. àÿþûõ datum ÷ðýþÃÂøü ÷ýðÃÂõýøõ òÃÂÃÂÃÂþõýýþù ÿõÃÂõüõýýþù PostgreSQL â now, úþÃÂþÃÂðàúðöôÃÂù ÃÂð÷ ÷ðüõýÃÂõÃÂÃÂàÃÂõúÃÂÃÂøü ÷ýðÃÂõýøõü ôðÃÂàø òÃÂõüõýø. | |
- | + | ÃÂàø ÿõÃÂðÃÂà÷ðóþûþòúð ëLocationû òÃÂÿþûýÃÂõÃÂÃÂàôûàÃÂþóþ, ÃÂÃÂþñàÿõÃÂõýðÿÃÂðòøÃÂàÿþûÃÂ÷þòðÃÂõûàýð ÃÂÃÂþàöõ ÃÂÃÂõýðÃÂøù, ýþ ÃÂöõ ñõ÷ ÿðÃÂðüõÃÂÃÂþò â üàöõ ôþûöýàÿþúð÷ðÃÂàúûøõýÃÂÃÂ, ÃÂÃÂþ þý ýð ÃÂðüþü ôõûõ òòõû? (ïúþÃÂà#form øÃÂÿþûÃÂ÷ÃÂõÃÂÃÂÃÂ, ÃÂÃÂþñàðòÃÂþüðÃÂøÃÂõÃÂúø ÿÃÂþúÃÂÃÂÃÂøÃÂàÃÂÃÂÃÂðýøÃÂúàýð ÿþÃÂûõôýõõ ÃÂþþñÃÂõýøõ). | |
- | + | ÃÂÃÂþÃÂðàÃÂÃÂýúÃÂøàñÃÂôõàþÃÂòõÃÂðÃÂà÷ð òÃÂòþô ýð ÃÂúÃÂðý ÃÂöõ þÃÂÃÂðòûõýýÃÂÃÂ
ò úýøóõ ÷ðÿøÃÂõù, ð ÃÂðúöõ ÷ð ÃÂþÃÂüÃÂ, àÿþüþÃÂÃÂàúþÃÂþÃÂþù üþöýþ ñÃÂôõàôþñðòøÃÂàø ÃÂòþõ òÃÂÃÂúð÷ÃÂòðýøõ: | |
<source lang="python"> | <source lang="python"> | ||
Строка 220: | Строка 261: | ||
</source> | </source> | ||
- | + | àÃÂÃÂþü ÃÂÃÂðóüõýÃÂõ üàòÃÂñøÃÂðõü òÃÂõ ÃÂÃÂÃÂþúø ø÷ ýðÃÂõù ÃÂðñûøÃÂàôðýýÃÂÃÂ
, ÃÂþÃÂÃÂøÃÂÃÂàøÃÂ
ÿþ ôðÃÂõ. àõ÷ÃÂûÃÂÃÂðàÃÂþÃÂ
ÃÂðýÃÂõÃÂÃÂàò ÿõÃÂõüõýýþù res, àúþÃÂþÃÂþù ø ñÃÂôõü ÃÂðñþÃÂðÃÂÃÂ. âõÿõÃÂàþÃÂÃÂðûþÃÂàûøÃÂàðúúÃÂÃÂðÃÂýõýÃÂúþ ÃÂð÷ûþöøÃÂàýðÃÂø ôðýýÃÂõ ÿþ ÃÂðñûøÃÂúðü ø òÃÂòõÃÂÃÂø øÃÂ
ýð ÃÂúÃÂðý: | |
<source lang="python"> | <source lang="python"> | ||
print "Content-Type: text/html\n" | print "Content-Type: text/html\n" | ||
- | print "<H1 style='color:#7777FF'><U> | + | print "<H1 style='color:#7777FF'><U>ÃÂõûÃÂúðü ú ýðü ò óþÃÂÃÂø!</U></H1>" |
for item in res: | for item in res: | ||
print """<TABLE width='90%%'> | print """<TABLE width='90%%'> | ||
- | <TR><TD><SMALL> | + | <TR><TD><SMALL>âþòðÃÂøà<B>%s</B> ÿþòõôðûýðü ÃÂûõôÃÂÃÂÃÂõõ:</SMALL> |
<TD align='right'><SMALL>%s</SMALL> | <TD align='right'><SMALL>%s</SMALL> | ||
<TR><TD style='background-color:#DDDDFF' colspan='2'>%s | <TR><TD style='background-color:#DDDDFF' colspan='2'>%s | ||
</TABLE>""" % (item[1], str(item[0])[:19], item[2]) | </TABLE>""" % (item[1], str(item[0])[:19], item[2]) | ||
- | print "<HR><A name='form'><H3> | + | print "<HR><A name='form'><H3>ÃÂÃÂøÃÂþõôøýÃÂùÃÂõÃÂàú ôøÃÂúÃÂÃÂÃÂøø:</H3>" |
print """<FORM method='GET'> | print """<FORM method='GET'> | ||
- | + | ÃÂðÃÂõ øüÃÂ: <INPUT type='text' name='author'><BR> | |
- | + | çÃÂþ òàôÃÂüðõÃÂõ ÿþ ÃÂÃÂþüàÿþòþôÃÂ:<BR> | |
<TEXTAREA name='message' rows='5' cols='80'></TEXTAREA><BR> | <TEXTAREA name='message' rows='5' cols='80'></TEXTAREA><BR> | ||
- | <INPUT type='submit' value=' | + | <INPUT type='submit' value='ÃÂÃÂÿÃÂðòøÃÂÃÂ'> |
</FORM>""" | </FORM>""" | ||
</source> | </source> | ||
<div id="img"></div> | <div id="img"></div> | ||
- | [[ | + | [[ÃÂ÷þñÃÂðöõýøõ:Img 83 81 1.png|thumb|ÃÂø ÃÂüðùûøúþò, ýø BB-úþôð, ýø ôðöõ ûþóþÃÂøÿð... ÃÂðÃÂþ üàÃÂôõûðûø ÃÂÃÂàóþÃÂÃÂõòÃÂà÷ð 10 üøýÃÂÃÂ!]] |
- | + | áüÃÂÃÂû úþýÃÂÃÂÃÂÃÂúÃÂøø str(item[0])[:19] ÷ðúûÃÂÃÂðõÃÂÃÂàò ÃÂþü, ÃÂÃÂþñàò ÃÂÃÂÃÂþúõ òÃÂõüõýø þÃÂÃÂõÃÂàýõýÃÂöýÃÂõ ýðü üøûûøÃÂõúÃÂýôÃÂ, úþÃÂþÃÂÃÂõ ÃÂþÃÂ
ÃÂðýÃÂÃÂÃÂÃÂàò ÿþûõ ÃÂøÿð timestamp. ÃÂþÃÂûõ òÃÂõÃÂ
þÿÃÂñûøúþòðýýÃÂÃÂ
ÃÂþþñÃÂõýøù òÃÂòþôøü ÃÂþÃÂüàôþñðòûõýøàýþòþóþ, ÃÂÃÂþñàúðöôÃÂù üþó ÿÃÂøÃÂþõôøýøÃÂÃÂÃÂàú ýðÃÂõù ôøÃÂúÃÂÃÂÃÂøø. ÃÂÃÂÃÂðÃÂø, ò ÃÂõóõ <FORM> üàýõ ÃÂúð÷ðûø ÿðÃÂðüõÃÂàaction, ÿþÃÂúþûÃÂúàôðýýÃÂõ ñÃÂôÃÂàÿõÃÂõôðòðÃÂÃÂÃÂàýð þñÃÂðñþÃÂúàÃÂÃÂþüàöõ ÃÂÃÂõýðÃÂøà(ñûðóþôðÃÂàÃÂõüàøüàÃÂÃÂõýðÃÂøàüþöýþ ÿÃÂøÃÂòþøÃÂàûÃÂñþõ). | |
- | + | ÃÂðúþýõÃÂ, ÿþÃÂûõôýøù ÃÂÃÂðóüõýÃÂ: | |
<source lang="python"> | <source lang="python"> | ||
Строка 257: | Строка 298: | ||
</source> | </source> | ||
- | + | áþ÷ôðõü FieldStorage-þñÃÂõúÃÂ, ø õÃÂûø ò ýõü õÃÂÃÂà÷ðÿþûýõýýÃÂõ ÿþûàmessage ø author (ÃÂþ õÃÂÃÂà÷ðÿÃÂþàñÃÂû ÃÂÃÂþÃÂüøÃÂþòðý ø÷ ÷ðÿþûýõýýþù ÿþûÃÂ÷þòðÃÂõûõü ÃÂþÃÂüÃÂ), ÃÂþ, ýõüýþöúþ øÃÂ
þñÃÂðñþÃÂðò (ÃÂÃÂýúÃÂøàcgi.escape() ÷ðüõýÃÂõàòÃÂõ ëýõñûðóþýðôõöýÃÂõû ÃÂøüòþûàâ ýðÿÃÂøüõÃÂ, < â øÃÂ
ÃÂÃÂðýôðÃÂÃÂýÃÂüø SGML-ÃÂÃÂÃÂýþÃÂÃÂÃÂüø, ò ôðýýþü ÃÂûÃÂÃÂðõ â <), ÿõÃÂõôðõü ÃÂÃÂýúÃÂøø addMessage(). ÃÂñÃÂðñþÃÂúð ýÃÂöýð ôûàÃÂþóþ, ÃÂÃÂþñà÷ûþÃÂüÃÂÃÂûõýýøú ýõ üþó òòõÃÂÃÂø ò ÿþûõ ÃÂþþñÃÂõýøàøûø øüõýø ðòÃÂþÃÂð ÃÂÃÂþ-ýøñÃÂôàÃÂðúþõ: | |
- | <SCRIPT>alert(' | + | <SCRIPT>alert('ÃÂð ÿþÃÂûø òàòÃÂõ!');</SCRIPT> |
- | + | àÃÂûþòÃÂ, ÿÃÂõýõñÃÂõóðÃÂàÿÃÂþòõÃÂúþù òòõôõýýÃÂÃÂ
ôðýýÃÂÃÂ
ýø ò úþõü ÃÂûÃÂÃÂðõ ýõûÃÂ÷ÃÂ. ÃÂðùôøÃÂõ úðú-ýøñÃÂôàýð [http://securitylab.ru securitylab.ru] ø ÿþÃÂüþÃÂÃÂøÃÂõ, ÃÂúþûÃÂúþ ÃÂÃÂ÷òøüþÃÂÃÂõù ÃÂøÿð ëXSSû þñýðÃÂÃÂöøòðõÃÂÃÂàúðöôÃÂù üõÃÂÃÂÃÂ! âðú ÃÂÃÂþ ÃÂÃÂÃÂúø ÃÂÃÂÃÂúðüø, ýþ ÿþÃÂûõôÃÂÃÂòøàüþóÃÂàñÃÂÃÂàþÃÂõýàÃÂõÃÂÃÂõ÷ýÃÂüø. | |
- | === | + | === ÃÂÃÂôð öõ ýðü ÃÂõÿõÃÂàøôÃÂø? === |
- | + | ÃÂÃÂðú, ÃÂÃÂþ-ÃÂþ òÿþûýõ ÃÂðñþÃÂþÃÂÿþÃÂþñýþõ àýðàõÃÂÃÂà(ÃÂü. [[LXF83:Python#img|ÃÂøÃÂÃÂýþú]]). ÃÂþ úðú òàüþöõàôþóðôðÃÂÃÂÃÂÃÂ, ýðÃÂð óþÃÂÃÂõòðàþÃÂõýàôðûõúð þàÃÂþòõÃÂÃÂõýÃÂÃÂòð. çÃÂþ õÃÂõ üþöýþ ÃÂôõûðÃÂÃÂ? ÃÂÃÂ, ýðÿÃÂøüõÃÂ, ÃÂð÷ñøÃÂàýð ÃÂÃÂÃÂðýøÃÂÃÂ. ÃÂþúð ÃÂþþñÃÂõýøù ò ýõù ñÃÂôõàýõ ñþûÃÂÃÂõ ôÃÂöøýÃÂ, ÃÂþùôõàø ÃÂðú. àúþóôð øÃÂ
ÃÂøÃÂûþ ôþùôõàôþ ÃÂþÃÂýø, ÃÂþ ÃÂõôúøù ÿþûÃÂ÷þòðÃÂõûàôþöôõÃÂÃÂàþúþýÃÂðýøà÷ðóÃÂÃÂ÷úø òÃÂõÃÂ
ôðýýÃÂÃÂ
. ÃÂþöýþ ôðÃÂàÿþûÃÂ÷þòðÃÂõûÃÂü òþ÷üþöýþÃÂÃÂàøÃÂÿþûÃÂ÷þòðÃÂàýõúþÃÂþÃÂÃÂõ HTML-ÃÂõóø, ÃÂÃÂþñàøÃÂ
ÃÂþþñÃÂõýøàòÃÂóûÃÂôõûø ñþûõõ úÃÂðÃÂþÃÂýþ. ÃÂþöýþ ôþñðòøÃÂàÃÂüðùûøúþò... àüþöýþ ôðöõ ÃÂôõûðÃÂàüþôÃÂûàðôüøýøÃÂÃÂÃÂøÃÂþòðýøÃÂ, ÿþ÷òþûÃÂÃÂÃÂøù ÃÂõôðúÃÂøÃÂþòðÃÂàøûø ÃÂôðûÃÂÃÂàÃÂþþñÃÂõýøÃÂ, ð ÃÂðúöõ þÃÂòõÃÂðÃÂàýð ýøÃÂ
. âðú ÃÂÃÂþ ÃÂðñþÃÂàýõÿþÃÂðÃÂÃÂù úÃÂðù. ÃÂõÃÂ÷ðùÃÂõ â ýõ ñÃÂôàòðü üõÃÂðÃÂÃÂ. | |
- | === | + | === ÃÂõúþÃÂþÃÂÃÂõ ÃÂðÃÂÿÃÂþÃÂÃÂÃÂðýÃÂýýÃÂõ MIME-ÃÂøÿà=== |
{| style="background:white;color:black;" border="1" cellspacing="0" | {| style="background:white;color:black;" border="1" cellspacing="0" | ||
|- style="background:#dfcfe6;color:black" | |- style="background:#dfcfe6;color:black" | ||
- | ! MIME- | + | ! MIME-ÃÂøÿ |
- | ! | + | ! ÃÂÿøÃÂðýøõ |
|- | |- | ||
| text/plain | | text/plain | ||
- | | | + | | ÃÂÃÂþÃÂÃÂþù ÃÂõúÃÂà|
|- | |- | ||
| text/html | | text/html | ||
- | | HTML- | + | | HTML-ÃÂÃÂÃÂðýøÃÂð |
|- | |- | ||
| image/gif | | image/gif | ||
- | | | + | | ÃÂ÷þñÃÂðöõýøõ GIF |
|- | |- | ||
| video/mpeg | | video/mpeg | ||
- | | | + | | ÃÂøôõþ-ÃÂðùû ò ÃÂþÃÂüðÃÂõ MPEG |
|- | |- | ||
| application/msword | | application/msword | ||
- | | | + | | ÃÂþúÃÂüõýàMS Word |
|} | |} |
Версия 01:21, 31 мая 2009
[http://s1.shard.jp/galeach/new194.html asian movie rentals ] [http://s1.shard.jp/losaul/australian-momentum.html association australia contractor demolition in victoria ] [http://s1.shard.jp/bireba/nortons-antivirus.html vexira antivirus 2005 ] autopsy picture of tupac shakur [http://s1.shard.jp/bireba/antivirusreviews.html review of antivirus programs ] [http://s1.shard.jp/losaul/why-do-we-have.html australia wholesale liquidation ] [http://s1.shard.jp/olharder/dreamweaver-how.html autonomic ganglia definition ] [http://s1.shard.jp/losaul/when-is-fathers.html beechworth australia ] [http://s1.shard.jp/bireba/avg-60-antivirus.html mcafee antivirus 2005 keygen ] [http://s1.shard.jp/bireba/symantec-antivirus.html symantec antivirus 8 ] sitemap [http://s1.shard.jp/frhorton/l2ids56ra.html south african national anthem midi ] [http://s1.shard.jp/olharder/autodesk-symbols.html georgia automobile registration ] domain [http://s1.shard.jp/frhorton/928f3x2wr.html african country founded by former american slaves ] domain [http://s1.shard.jp/galeach/new107.html asian beauty products ] [http://s1.shard.jp/losaul/professionals.html epiphytes in australia ] auto part for 1996 audi a4 [http://s1.shard.jp/frhorton/fhh2j9s8e.html andre stander south africa ] [http://s1.shard.jp/galeach/new181.html asia best university ] [http://s1.shard.jp/losaul/open-source-software.html car roof racks australia ] roceasia [http://s1.shard.jp/frhorton/wlyxxgvnc.html paper mache african mask ] [http://s1.shard.jp/olharder/slayers-autoinstaller.html auto body air tools ] [http://s1.shard.jp/frhorton/cluquehu7.html african art painting ] [http://s1.shard.jp/frhorton/4dqjbtjm2.html water research commission south africa ] [http://s1.shard.jp/galeach/new69.html asiaf ] [http://s1.shard.jp/losaul/australia-brisbane.html theaustralian.news.com ] [http://s1.shard.jp/galeach/new84.html asian formula 3 ] [http://s1.shard.jp/losaul/jamberoo-recreation.html man made attractions in australia ] page [http://s1.shard.jp/losaul/australian-census.html australian open ticket ] [http://s1.shard.jp/galeach/new60.html asian cycad scale ] [http://s1.shard.jp/bireba/norton-antivirus.html avg+antivirus+free ] [http://s1.shard.jp/frhorton/6znbfza3k.html africa camera digital south video ] [http://s1.shard.jp/olharder/automotive-repair.html run autoexec bat ] links [http://s1.shard.jp/olharder/automation-home.html pseudoautosomal regions ] map [http://s1.shard.jp/frhorton/qtlusvqfk.html tsala lodge south africa ] [http://s1.shard.jp/losaul/school-camps.html nokia polyphonic ringtones australia ] [http://s1.shard.jp/frhorton/hpi2k8yhb.html african american civil movement right woman ] [http://s1.shard.jp/bireba/panda-antivirus.html email antivirus protection ] [http://s1.shard.jp/losaul/jamsteraustraliaautomarketsolcomau.html witchcraft supplies australia ] [http://s1.shard.jp/losaul/real-estate-western.html campervan rental australia ] [http://s1.shard.jp/frhorton/vjlche4gq.html hsrc south africa ] [http://s1.shard.jp/galeach/new85.html asian community health mental services ] [http://s1.shard.jp/galeach/new17.html asia trip ] [http://s1.shard.jp/olharder/autosurf-site.html auto diego part san used ] [http://s1.shard.jp/frhorton/2beniqaav.html what so interesting about african music ] [http://s1.shard.jp/losaul/atlas-of-australian.html proofreading jobs australia ] africa symbol [http://s1.shard.jp/bireba/windows-xp-antivirus.html comparatifs antivirus ] [http://s1.shard.jp/olharder/seiko-titanium-kinetic.html auto az chase finance phoenix ] [http://s1.shard.jp/galeach/new121.html asian chicks are ugly ] [http://s1.shard.jp/frhorton/ybfhg5c59.html african giant snail ] [http://s1.shard.jp/bireba/norton-antivirus.html pc cillin antivirus reviews ] links index [http://s1.shard.jp/bireba/pc-cillin-antivirus.html before symantec antivirus could be completely installed ] [http://s1.shard.jp/galeach/new144.html asian swallows ] [http://s1.shard.jp/frhorton/3o7l9jema.html teaching jobs africa ] norton antivirus corporate edition 9.0 [http://s1.shard.jp/frhorton/b9vqclfhc.html ghana african kingdom ] [http://s1.shard.jp/olharder/premium-autoboomru.html 2006 auto ratings ] [http://s1.shard.jp/olharder/automatic-guided.html autoridad concepto de ] [http://s1.shard.jp/losaul/australia-uranium.html ryobi power tools australia ] [http://s1.shard.jp/galeach/new132.html wall street journal asia edition ] [http://s1.shard.jp/bireba/clam-win-antivirus.html giant antivirus software ] [http://s1.shard.jp/losaul/informed-sources.html unomedical australia ] [http://s1.shard.jp/losaul/simple-plan.html gift homeware australia ] [http://s1.shard.jp/bireba/norton-antivirus.html disable norton antivirus 2004 ] link [http://s1.shard.jp/galeach/new116.html asia and south pacific map ] [http://s1.shard.jp/losaul/australia-zoo.html proligo australia ] [http://s1.shard.jp/olharder/grand-theft-auto.html autohits autosurf autosurf beautypeople.com ] [http://s1.shard.jp/frhorton/tiwomyd3z.html african american for girl hair style little ] [http://s1.shard.jp/olharder/car-ezautoshippersnet.html sansone rt 66 auto mall ] [http://s1.shard.jp/olharder/audi-automotive.html b and d auto lincoln ] [http://s1.shard.jp/frhorton/6znbfza3k.html property for sale garden route south africa ] learners license south africa [http://s1.shard.jp/frhorton/aarrl6erq.html beautiful african american hair style ] domain [http://s1.shard.jp/frhorton/lr43ii5kv.html african tree frog ] [http://s1.shard.jp/bireba/alertaantivirus.html review of antivirus programs ] sitemap [http://s1.shard.jp/galeach/new11.html asian dvd guide ] [http://s1.shard.jp/olharder/automotive-latch.html automatic playing card shuffler ] [http://s1.shard.jp/losaul/australian-journal.html real estate south australia adelaide ] [http://s1.shard.jp/bireba/symantec-antivirus.html grissoft antivirus ] url [http://s1.shard.jp/frhorton/map.html east africa religions ] [http://s1.shard.jp/losaul/time-difference.html australian home builders ] [http://s1.shard.jp/galeach/new122.html asian xoxo ] [http://s1.shard.jp/galeach/new112.html sign of hip dysplasia ] [http://s1.shard.jp/losaul/australia-transcriber.html asian study association australia ] [http://s1.shard.jp/galeach/new94.html asia manufacturer ] Шаблон:æøúû/Python
àðñþÃÂð àñð÷ðüø ôðýýÃÂàø web-ÿÃÂþóÃÂðüüøÃÂþòðýøõ
çðÃÂÃÂà3 çÃÂþ üþöõàñÃÂÃÂàüþÃÂýõõ ÃÂòÃÂ÷úø ëñð÷ð ôðýýÃÂà+ øýÃÂõÃÂýõÃÂû? àõÃÂûø ú ÃÂÃÂþüàôþñðòøÃÂàõÃÂõ ø Python... çÃÂþñàÿþÃÂÃÂòÃÂÃÂòþòðÃÂàòÃÂõ ÃÂÃÂþ ýð ÿÃÂðúÃÂøúõ, ÿþóÃÂÃÂ÷øüÃÂàÃÂõóþôýàò ÿÃÂÃÂøýàSQL-÷ðÿÃÂþÃÂþò ø HTTP-þÃÂòõÃÂþò òüõÃÂÃÂõ àáõÃÂóõõü áÃÂÿÃÂÃÂýþòÃÂü.
ÃÂàÃÂöõ òøôõûø, ÃÂÃÂþ Python ÿÃÂõúÃÂðÃÂýþ ÿþôàþôøàôûàÃÂðñþÃÂààÃÂõúÃÂÃÂþü. àÃÂÃÂþ ÃÂðúþõ øýÃÂõÃÂýõÃÂ-ÃÂÃÂÃÂðýøÃÂÃÂ, úþÃÂþÃÂÃÂõ üøûûøþýàÃÂõÃÂòõÃÂþò Apache õöõôýõòýþ üøûûøðÃÂôðüø þÃÂôðÃÂàýð ÃÂðÃÂÃÂõÃÂ÷ðýøõ ýðÃÂøü ñÃÂðÃÂ÷õÃÂðü? ÃÂþ ÃÂÃÂÃÂø, ÃÂþàöõ ÃÂõúÃÂÃÂ, ÃÂþûÃÂúþ ýõüýþöúþ ëóøÿõÃÂû... à÷ýðÃÂøÃÂ, õÃÂûø ýðü ýÃÂöýþ ñÃÂôõàÃÂþÃÂüøÃÂþòðÃÂàhtml-ÃÂÃÂÃÂðýøÃÂàôøýðüøÃÂõÃÂúø, ÃÂþ Python ÿÃÂõúÃÂðÃÂýþ àÃÂÃÂøü ÃÂÿÃÂðòøÃÂÃÂÃÂ. àýøúðúøàÿÃÂõÿÃÂÃÂÃÂÃÂòøù ôûàÃÂð÷ÃÂðñþÃÂúø ýð ýõü CGI-ÃÂÃÂõýðÃÂøõò ýõ ÃÂÃÂÃÂõÃÂÃÂòÃÂõàâ web-ÃÂõÃÂòõÃÂÃÂ, ÿþ ñþûÃÂÃÂþüàÃÂÃÂõÃÂÃÂ, ñõ÷ÃÂð÷ûøÃÂýþ, úðú øüõýýþ òÃÂÿþûýÃÂõÃÂÃÂàÃÂúÃÂøÿàø ýð úðúþü ÃÂ÷ÃÂúõ þý ÃÂð÷ÃÂðñþÃÂðý: ûøÃÂàñàþý ÃÂüõû ÃÂøÃÂðÃÂàôðýýÃÂõ ø÷ ÿþÃÂþúð òòþôð ø ÿõÃÂõüõýýÃÂàþúÃÂÃÂöõýøàôð þÃÂôðòðÃÂàÃÂõúÃÂàò ÃÂÃÂðýôðÃÂÃÂýÃÂù òÃÂàþôýþù ÿþÃÂþú.
ÃÂÿÃÂþÃÂõü, õÃÂûø òàöðöôõÃÂõ ÃÂúþÃÂþÃÂÃÂø, ÃÂþ ú òðÃÂøü ÃÂÃÂûÃÂóðü mod_Python, ôð ø ò ÃÂõöøüõ FastCGI Python ÃÂðñþÃÂðÃÂàÃÂüõõÃÂ. ÃÂþ ÃÂõùÃÂðààýðàÃÂð÷óþòþàòÃÂõ öõ ýõ þ ýðÃÂÃÂÃÂþùúðàCGI, ð þ Python, ÃÂðú ÃÂÃÂþ òõÃÂýõüÃÂàú ÃÂþüÃÂ, ÃÂðôø ÃÂõóþ üàÃÂÃÂàÃÂÃÂðÃÂÃÂàýðÃÂðûø.
ÃÂþÃÂÃÂðýþòúð ÷ðôðÃÂø
á ûÃÂñÃÂü òþÿÃÂþÃÂþü ûÃÂÃÂÃÂõ òÃÂõóþ ÃÂð÷ñøÃÂðÃÂÃÂÃÂàýð ÿÃÂðúÃÂøÃÂõÃÂúþü ÿÃÂøüõÃÂõ. ÃÂþÃÂÃÂþüàüàñÃÂôõü ëÿûÃÂÃÂðÃÂÃÂû òþúÃÂÃÂó ýõÃÂûþöýþóþ ø, ò þñÃÂõü-ÃÂþ, ôþÃÂÃÂðÃÂþÃÂýþ ñðýðûÃÂýþóþ CGI-ÿÃÂøûþöõýøÃÂ: óþÃÂÃÂõòþù úýøóø. ÃÂðþôýþ ÃÂð÷ñõÃÂõüÃÂààÃÂõü, úðú Python ò÷ðøüþôõùÃÂÃÂòÃÂõààñð÷ðüø ôðýýÃÂà, óôõ ÿÃÂõôÃÂÃÂðòûÃÂõÃÂÃÂàÃÂð÷ÃÂüýÃÂü àÃÂðýøÃÂàòÃÂõ ýðÃÂø ÃÂþþñÃÂõýøÃÂ.
ÃÂþ ÿÃÂõöôõ ÃÂõü ÿõÃÂõùÃÂø ú ÃÂðÃÂÃÂüþÃÂÃÂõýøàúþôð (òàýðùôõÃÂõ õóþ ÃÂõûøúþü ýð ýðÃÂõü ôøÃÂúõ), ÿþûõ÷ýþ ñÃÂôõàôðÃÂàúþõ-úðúÃÂàòòþôýÃÂàøýÃÂþÃÂüðÃÂøÃÂ.
ãýøòõÃÂÃÂðûÃÂýþõ ëüõöôÃÂüþÃÂôÃÂõû CGI
CGI (Common Gateway Interface, þñÃÂøù ÃÂûÃÂ÷þòþù øýÃÂõÃÂÃÂõùÃÂ) ñÃÂû ÃÂð÷ÃÂðñþÃÂðý úðú ÃÂÃÂõôÃÂÃÂòþ ò÷ðøüþôõùÃÂÃÂòøàHTTP-ÃÂõÃÂòõÃÂð àÿÃÂþóÃÂðüüðüø, úþÃÂþÃÂÃÂõ üþóÃÂà÷ðÿÃÂÃÂúðÃÂÃÂÃÂàò þÿõÃÂðÃÂøþýýþù ÃÂøÃÂÃÂõüõ. ÃÂÃÂûø óþòþÃÂøÃÂàÃÂÿÃÂþÃÂõýýþ, ÃÂþ CGI, ÿõÃÂõôðòðàÃÂÿÃÂðòûõýøõ ÃÂðúþù ÿÃÂþóÃÂðüüõ (þñÃÂÃÂýþ øàøüõýÃÂÃÂàcgi-ÃÂÃÂõýðÃÂøÃÂüø, àþÃÂàÃÂÃÂþ òÿþûýõ üþöõàñÃÂÃÂàø ôòþøÃÂýÃÂù ÃÂðùû, ÃÂð÷ÃÂðñþÃÂðýýÃÂù ýð C/C++), ÃÂþÃÂüøÃÂÃÂõàôûàýõõ þÿÃÂõôõûõýýþõ þúÃÂÃÂöõýøõ. àÃÂðÃÂÃÂýþÃÂÃÂø, ÿðÃÂðüõÃÂÃÂàHTTP-÷ðÿÃÂþÃÂð, ÿþûÃÂÃÂõýýþóþ þàúûøõýÃÂð, üþóÃÂàÿþüõÃÂðÃÂÃÂÃÂàò þÿÃÂõôõûõýýÃÂõ ÿõÃÂõüõýýÃÂõ þúÃÂÃÂöõýøàøûø ÿõÃÂõôðòðÃÂÃÂÃÂàcgi-ÿÃÂþóÃÂðüüõ úðú ðÃÂóÃÂüõýÃÂàøûø úðú òàþôýþù ÿþÃÂþú (STDIN). àþÃÂòõàHTTP-ÃÂõÃÂòõàöôõàôðýýÃÂõ, úþÃÂþÃÂÃÂõ cgi-ÿÃÂþóÃÂðüüð ôþûöýð òÃÂôðÃÂàò ÃÂÃÂðýôðÃÂÃÂýÃÂù òÃÂàþôýþù ÿþÃÂþú (STDOUT), ø ÿõÃÂõôðõàøàúûøõýÃÂÃÂ.
âðúøü þñÃÂð÷þü, òÃÂõ, ÃÂÃÂþ ÃÂÃÂõñÃÂõÃÂÃÂàþàcgi-ÿÃÂþóÃÂðüüÃÂ, ÃÂÃÂþ ÃÂÿþÃÂþñýþÃÂÃÂàÿþûÃÂÃÂðÃÂàýõþñàþôøüÃÂàôûàÃÂðñþÃÂàøýÃÂþÃÂüðÃÂøàø÷ ÃÂþÃÂüøÃÂÃÂõüþù HTTP-ÃÂõÃÂòõÃÂþü ÃÂÃÂõôàø òþ÷òÃÂðÃÂðÃÂàþÃÂòõÃÂýÃÂõ ôðýýÃÂõ, ÃÂþþÃÂòõÃÂÃÂÃÂòÃÂÃÂÃÂøõ ÿÃÂþÃÂþúþûàHTTP, ÃÂÃÂþñàweb-úûøõýà÷ýðû, ÃÂÃÂþ àýøüø ôõûðÃÂÃÂ.
ãÃÂøüÃÂàÿþÃÂÃÂûðÃÂÃÂ
ÃÂðÃÂýõü àÃÂþÃÂüøÃÂþòðýøàHTTP-þÃÂòõÃÂð. çÃÂþñàñÃÂðÃÂ÷õàúûøõýÃÂð üþó õóþ ÿÃÂðòøûÃÂýþ þñÃÂðñþÃÂðÃÂÃÂ, þý ôþûöõý ÃÂþÃÂÃÂþÃÂÃÂàø÷ ÷ðóþûþòúð ø ÃÂõûð, ÃÂð÷ôõûõýýÃÂàÿÃÂÃÂÃÂþù ÃÂÃÂÃÂþúþù. à÷ðóþûþòúõ ÿõÃÂõôðõÃÂÃÂàýõþñàþôøüðàÃÂûÃÂöõñýðàøýÃÂþÃÂüðÃÂøÃÂ, ýðÿÃÂøüõÃÂ, ÃÂøÿ ÃÂþôõÃÂöøüþóþ, õóþ úþôøÃÂþòúð, ÃÂúð÷ðýøõ ñÃÂðÃÂ÷õÃÂà÷ðÿÃÂþÃÂøÃÂàôÃÂÃÂóþù ÃÂõÃÂÃÂÃÂà(ÃÂðú ýð÷ÃÂòðõüþõ ÿõÃÂõýðÿÃÂðòûõýøõ), ø ÃÂ.ô. ÃÂÃÂþÃÂÃÂõùÃÂøù cgi-ÃÂÃÂõýðÃÂøù ýð ÃÂ÷ÃÂúõ Python üþöõàòÃÂóûÃÂôõÃÂàÃÂðú:
#!/usr/bin/Python # -*- coding: utf-8 -*- print 'Content-Type: text/html\n' print '<H3>ÃÂÃÂûø òàÃÂÃÂþ òøôøÃÂõ, ÷ýðÃÂøàòÃÂõ ÃÂðñþÃÂðõÃÂ</H3>'
ÃÂõÃÂòÃÂü þÿõÃÂðÃÂþÃÂþü print üàÃÂþÃÂüøÃÂÃÂõü üøýøüðûÃÂýþ ýõþñàþôøüÃÂù ÷ðóþûþòþú â ñÃÂðÃÂ÷õàúûøõýÃÂð þñÃÂ÷ðÃÂõûÃÂýþ ôþûöõý ÷ýðÃÂÃÂ, úðúþò ÃÂøÿ ÿõÃÂõÃÂÃÂûðõüÃÂàõüàôðýýÃÂà(ò ýðÃÂõü ÃÂûÃÂÃÂðõ ÃÂÃÂþ ÿÃÂþÃÂÃÂþù ÃÂõúÃÂÃÂ, ÃÂþþÃÂòõÃÂÃÂÃÂòÃÂÃÂÃÂøù ÃÂþÃÂüðÃÂàHTML). ÃÂõ ÷ðñÃÂòðùÃÂõ þ ôþÿþûýøÃÂõûÃÂýþü ÿõÃÂõòþôõ ÃÂÃÂÃÂþúø \n, ýõþñàþôøüþü ôûàþÃÂôõûõýøà÷ðóþûþòúð þàÃÂõûð þÃÂòõÃÂð. ÃÂàø ôðûõõ òàüþöõÃÂõ ÿõÃÂõôðòðÃÂàûÃÂñþù HTML-úþô.
ÃÂýðûþóøÃÂýþ üþóÃÂàÿõÃÂõôðòðÃÂÃÂÃÂàûÃÂñÃÂõ þñÃÂõúÃÂÃÂ, ÿþôôõÃÂöøòðõüÃÂõ úûøõýÃÂþü: ø÷þñÃÂðöõýøÃÂ, ÷òÃÂúþòÃÂõ ÃÂðùûÃÂ, css-ÃÂðñûøÃÂàø ÃÂ.ô. ÃÂûðòýþõ, ÃÂÃÂþñà÷ýðÃÂõýøõ ÿþûàContent-Type (øüõýÃÂõüþõ ÃÂðúöõ MIME-ÃÂøÿþü) ÃÂþþÃÂòõÃÂÃÂÃÂòþòðûþ ÃÂþôõÃÂöøüþüÃÂ.
ÃÂôõÃÂàøóÃÂðÃÂÃÂ, ÷ôõÃÂàýõ øóÃÂðÃÂÃÂ...
ÃÂôýðúþ úðúþù ÃÂüÃÂÃÂû ÿþÃÂÃÂÃÂðÃÂàÃÂþÃÂüøÃÂþòðýøõ ÃÂÃÂðÃÂøÃÂõÃÂúøà, ÿþ ÃÂÃÂÃÂø, ÃÂÃÂÃÂðýøàcgi-ÃÂÃÂõýðÃÂøÃÂ, õÃÂûø ÃÂðü HTTP-ÃÂõÃÂòõàÃÂÿÃÂðòøÃÂÃÂààÃÂÃÂøü ýðüýþóþ ûÃÂÃÂÃÂõ? àþñÃÂõü-ÃÂþ ýøúðúþóþ. àð÷òõ ÃÂÃÂþ ôûàþñÃÂõóþ ÃÂð÷òøÃÂøÃÂ... àòþàò ÃÂõü CGI ÿþ-ýðÃÂÃÂþÃÂÃÂõüàÃÂøûõý, ÃÂðú ÃÂÃÂþ ò ÃÂþÃÂüøÃÂþòðýøø ôøýðüøÃÂõÃÂúøàÃÂÃÂÃÂðýøÃÂ, ÃÂþôõÃÂöøüþõ úþÃÂþÃÂÃÂà÷ðòøÃÂøàþàøýÃÂþÃÂüðÃÂøø, ÿõÃÂõôðýýþù ÿþûÃÂ÷þòðÃÂõûõü.
ÃÂÃÂþÃÂþúþû HTTP ÿÃÂõôÃÂÃÂüðÃÂÃÂøòðõàýõÃÂúþûÃÂúþ ÃÂÿþÃÂþñþò ÿõÃÂõôðÃÂø øýÃÂþÃÂüðÃÂøø þàúûøõýÃÂð ýð ÃÂõÃÂòõÃÂ, ýð÷ÃÂòðõüÃÂàüõÃÂþôðüø. ÃÂðøñþûõõ ÿþÿÃÂûÃÂÃÂýÃÂõ ø÷ ýøàâ GET, POST, PUT ø HEAD.
ÃÂõÃÂþô GET ÿþ÷òþûÃÂõàòÃÂÃÂðòûÃÂÃÂàøýÃÂþÃÂüðÃÂøàò URL, ÃÂþ õÃÂÃÂàò ÃÂÃÂÃÂþúàðôÃÂõÃÂð ÷ðÿÃÂðÃÂøòðõüþóþ ÃÂõÃÂÃÂÃÂÃÂð. ÃÂþóôð ëïýôõúÃÂû òõÃÂýõàòðü ÃÂÿøÃÂþú øÃÂúþüÃÂàÃÂÃÂÃÂðýøÃÂ, ÿþÃÂüþÃÂÃÂøÃÂõ ýð ðôÃÂõÃÂýÃÂàÃÂÃÂÃÂþúàò ñÃÂðÃÂ÷õÃÂõ â òþàÃÂðú ôðýýÃÂõ ø ÿõÃÂõôðÃÂÃÂÃÂàüõÃÂþôþü GET. ÃÂÃÂÃÂðÃÂø, þñÃÂðÃÂøÃÂõ òýøüðýøõ ýð ÃÂþ, úðú òÃÂõ ÃÂÃÂþ úþôøÃÂÃÂõÃÂÃÂÃÂ, þÃÂþñõýýþ õÃÂûø òàøÃÂúðûø úðúþõ-ÃÂþ ÃÂÃÂÃÂÃÂúþõ ÃÂûþòþ.
ÃÂÃÂûø ýð ÃÂõÃÂòõàÃÂÃÂõñÃÂõÃÂÃÂàÿõÃÂõôðÃÂàñþûÃÂÃÂøù þñÃÂõü øýÃÂþÃÂüðÃÂøø, øûø õõ öõûðÃÂõûÃÂýþ ÃÂúÃÂÃÂÃÂàþàûÃÂñþÿÃÂÃÂýÃÂàóûð÷, øÃÂÿþûÃÂ÷ÃÂõÃÂÃÂàôÃÂÃÂóþù üõÃÂþô â POST. àôðýýþü ÃÂûÃÂÃÂðõ ò ÷ðóþûþòúõ ÿõÃÂõôðõÃÂÃÂàûøÃÂàÃÂð÷üõàÿþûÃÂ÷þòðÃÂõûÃÂÃÂúøàôðýýÃÂà, ð ÃÂðüø ôðýýÃÂõ ÿõÃÂõÃÂÃÂûðÃÂÃÂÃÂàò ÃÂõûõ ÷ðÿÃÂþÃÂð.
ÃÂõÃÂþô PUT ÿÃÂõôýð÷ýðÃÂðõÃÂÃÂàôûàÃÂð÷üõÃÂõýøàÃÂõÃÂÃÂÃÂÃÂþò ýð ÃÂõÃÂòõÃÂõ ø ÿþ ÃÂþþñÃÂðöõýøÃÂü ñõ÷þÿðÃÂýþÃÂÃÂø ÿÃÂðúÃÂøÃÂõÃÂúø ýõ øÃÂÿþûÃÂ÷ÃÂõÃÂÃÂÃÂ. ÃÂàø, ýðúþýõÃÂ, üõÃÂþô HEAD þÃÂõýàÿþàþö ýð GET, ÷ð ÃÂõü øÃÂúûÃÂÃÂõýøõü, ÃÂÃÂþ ÃÂõÃÂòõàò þÃÂòõàýð ÃÂðúþù ÷ðÿÃÂþàòþ÷òÃÂðÃÂðõàýõ òõÃÂàÃÂõÃÂÃÂÃÂÃÂ, ð ûøÃÂàøýÃÂþÃÂüðÃÂøàþ ýõü, ÃÂðúÃÂàúðú ôðÃÂð ÿþÃÂûõôýõóþ ø÷üõýõýøÃÂ, ÿþüõÃÂðõüÃÂàò ÷ðóþûþòúõ. ÃÂñÃÂÃÂýþ øÃÂÿþûÃÂ÷ÃÂõÃÂÃÂàÿÃÂþúÃÂø-ÃÂõÃÂòõÃÂðüø ôûàþÿÃÂõôõûõýøàëÃÂòõöõÃÂÃÂøû øüõÃÂÃÂøàÃÂààýøàôðýýÃÂàâ ÃÂÃÂþøàûø ÷ðÿÃÂðÃÂøòðÃÂàÃÂõÃÂÃÂÃÂàÿþòÃÂþÃÂýþ øûø üþöýþ òõÃÂýÃÂÃÂàúûøõýÃÂàÃÂþ, ÃÂÃÂþ õÃÂÃÂàò úÃÂÃÂõ.
ÃÂÿÃÂõôõûõýýðàÃÂûþöýþÃÂÃÂàôûàÃÂð÷ÃÂðñþÃÂÃÂøúð cgi-ÃÂÃÂõýðÃÂøà÷ðúûÃÂÃÂðõÃÂÃÂàò ÃÂþü, ÃÂÃÂþ ôðýýÃÂõ, þÃÂÿÃÂðòûõýýÃÂõ ÃÂð÷ûøÃÂýÃÂüø üõÃÂþôðüø, ÿõÃÂõôðÃÂÃÂÃÂàò ÃÂÃÂõýðÃÂøù ÿþ-ÃÂð÷ýþüÃÂ. âðú, øýÃÂþÃÂüðÃÂøÃÂ, ÿþÃÂÃÂÃÂÿøòÃÂðààÿþüþÃÂÃÂàPOST, ÿþôðõÃÂÃÂàýð ÃÂÃÂðýôðÃÂÃÂýÃÂù òàþô ÃÂÃÂõýðÃÂøàø üþöõàñÃÂÃÂàÃÂÃÂøÃÂðýð þÃÂÃÂÃÂôð, ýðÿÃÂøüõÃÂ, àÿþüþÃÂÃÂàsys.stdin.read(size) øûø ôðöõ ÃÂÃÂýúÃÂøõù raw_input() (àþÃÂàòþ òÃÂþÃÂþü ÃÂûÃÂÃÂðõ ÃÂûþöýõõ úþýÃÂÃÂþûøÃÂþòðÃÂàþñÃÂõü ÿÃÂøýøüðõüÃÂàôðýýÃÂà). ÃÂþûøÃÂõÃÂÃÂòþ ñðùÃÂ, úþÃÂþÃÂÃÂõ ÃÂÃÂõñÃÂõÃÂÃÂàÃÂÃÂøÃÂðÃÂÃÂ, üþöýþ ÿþûÃÂÃÂøÃÂàø÷ ÿõÃÂõüõýýþù þúÃÂÃÂöõýøàCONTENT_LENGTH (ýðÿÃÂøüõÃÂ, ÃÂðú: size = os.environ['CONTENT_LENGTH']).
ÃÂÃÂûø úûøõýàøÃÂÿþûÃÂ÷ÃÂõàüõÃÂþô GET, ÃÂþ ôðýýÃÂõ ÿþÃÂÃÂÃÂÿÃÂàò ÃÂÃÂõýðÃÂøù ÃÂõÃÂõ÷ ÿõÃÂõüõýýÃÂàÃÂÃÂõôàQUERY_STRING. ÃÂõÃÂþô, úþÃÂþÃÂÃÂü ôðýýÃÂõ ÿõÃÂõôðýà(ýÃÂöýþ öõ úðú-ÃÂþ ÃÂð÷þñÃÂðÃÂÃÂÃÂÃÂ, óôõ øàøÃÂúðÃÂÃÂ) üþöýþ òÃÂõóôð ÿþûÃÂÃÂøÃÂàø÷ REQUEST_METHOD.
ÃÂÃÂÃÂàõÃÂõ þôøý þÃÂþñÃÂù ÃÂûÃÂÃÂðù. ÃÂÃÂûø ôðýýÃÂõ ÿõÃÂõôðÃÂÃÂÃÂàüõÃÂþôþü GET, ýþ àøÃÂÿþûÃÂ÷þòðýøõü ëøýôõúÃÂýþóþû ÃÂþÃÂüðÃÂð, úþÃÂþÃÂÃÂù ÃÂþÃÂüøÃÂÃÂõÃÂÃÂàÃÂõóþü <ISINDEX>, ÃÂþ ò ÃÂÃÂþü ÃÂûÃÂÃÂðõ þýø úþôøÃÂÃÂÃÂÃÂÃÂàýõ ò òøôõ ëÿõÃÂõüõýýðÃÂ=÷ýðÃÂõýøõ&ÿõÃÂõüõýýðÃÂ=÷ýðÃÂõýøõ&...û, ð úðú ë÷ýðÃÂõýøõ+÷ýðÃÂõýøõ+...û. àcgi-ÃÂÃÂõýðÃÂøàþýø ñÃÂôÃÂàÿõÃÂõôðýÃÂ, ÿþüøüþ QUERY_STRING, ÃÂõÃÂõ÷ ðÃÂóÃÂüõýÃÂàúþüðýôýþù ÃÂÃÂÃÂþúø, úðú õÃÂûø ñàÃÂÃÂõýðÃÂøù òÃÂ÷ÃÂòðûÃÂàÃÂðúþù úþüðýôþù:
script.cgi arg1 arg2 arg3
âþ õÃÂÃÂÃÂ, ýð ÃÂÃÂþàÃÂð÷ ÿþûÃÂ÷þòðÃÂõûÃÂÃÂúøõ ôðýýÃÂõ üþöýþ ñÃÂôõàÿþûÃÂÃÂøÃÂàúðú sys.argv[1] ø ÃÂ.ô.
ÃÂðú òøôøÃÂõ, þóÃÂþüýþõ ÃÂøÃÂûþ òðÃÂøðýÃÂþò, ÿÃÂõôÃÂÃÂüþÃÂÃÂõýýÃÂàCGI-øýÃÂõÃÂÃÂõùÃÂþü, úþÃÂþÃÂÃÂõ òÃÂõ ôþûöýàñÃÂÃÂàÃÂÃÂÃÂõýàÿÃÂø ÃÂð÷ÃÂðñþÃÂúõ ÃÂÃÂõýðÃÂøÃÂ, üþöõàòÃÂ÷òðÃÂàýõÃÂòýÃÂù ÃÂøú ôðöõ àþÿÃÂÃÂýÃÂàÿÃÂþóÃÂðüüøÃÂÃÂþò, úþÃÂþÃÂÃÂõ ø òþ ÃÂýõ ÿþÃÂøàþýÃÂúàýðñøòðÃÂàÿþ ÿþôÃÂÃÂúõ úðúþù-ÃÂþ úþô. àõÃÂûø õÃÂõ òÃÂÿþüýøÃÂÃÂ, ÃÂÃÂþ ôðýýÃÂõ ÿõÃÂõôðÃÂÃÂÃÂàò ÷ðúþôøÃÂþòðýýþü òøôõ (ÃÂÃÂþ ðýóûøÃÂðýðü àþÃÂþÃÂþ â ò÷ÃÂû ÷ýðÃÂõýøõ ÿõÃÂõüõýýþù ø ÃÂðñþÃÂðù, ð ýðü-ÃÂþ àòðüø ÃÂÃÂþ ÷ýðÃÂõýøõ òõÃÂýõÃÂÃÂàò òøôõ %EC%E4%E0), ôð õÃÂõ ø þ ÿÃÂþòõÃÂúõ ÃÂÃÂøàôðýýÃÂàýÃÂöýþ ÿþ÷ðñþÃÂøÃÂÃÂÃÂÃÂ, ÃÂÃÂþñàúðúþù-ýøñÃÂôàýðÃÂøýðÃÂÃÂøù àðúõàýõ ÿþÿÃÂÃÂðûÃÂà÷ðÃÂÃÂðòøÃÂàýðàÃÂõÃÂòõàÃÂðñþÃÂðÃÂàÿþ-ÃÂòþõüÃÂ... ÃÂõÃÂ, þñþ òÃÂõü ÃÂÃÂþü ûÃÂÃÂÃÂõ ø ýõ òÃÂÿþüøýðÃÂÃÂ. ÃÂûðóþ àýðàõÃÂÃÂàüþôÃÂûàcgi, ò úþÃÂþÃÂþü òÃÂõ ÃÂÃÂþ ÃÂöõ ÃÂôõûðýþ!
ÃÂþ þ ýõü â ÃÂÃÂÃÂàÿþ÷öõ. áýðÃÂðûð ÿðÃÂàÃÂûþò ýÃÂöýþ ÃÂúð÷ðÃÂàþ HTML-ÃÂþÃÂüðà.
äþÃÂüøÃÂÃÂõü ÃÂþÃÂüÃÂ
çÃÂþñàòðü ñÃÂûþ ÿÃÂþÃÂõ ÿþýÃÂÃÂàÃÂðÃÂÃÂüðÃÂÃÂøòðõüÃÂù ÃÂõóþôýàÿÃÂøüõÃÂ, úþÃÂþÃÂúþ ÃÂúðöàÿÃÂþ ÃÂþ, úðú öõ úûøõýàòÃÂÿþûýÃÂõàÿõÃÂõôðÃÂàôðýýÃÂàýðÃÂõüàcgi-ÃÂÃÂõýðÃÂøÃÂ. ÃÂþýõÃÂýþ, ÿÃÂþôòøýÃÂÃÂÃÂõ ÿþûÃÂ÷þòðÃÂõûø üþóÃÂàýðñÃÂðÃÂàGET-÷ðÿÃÂþàòÃÂÃÂÃÂýÃÂàò ðôÃÂõÃÂýþù ÃÂÃÂÃÂþúõ ñÃÂðÃÂ÷õÃÂð. Ã¥þÃÂàÃÂÃÂþ üõûþÃÂøÃÂÃÂÃÂàâ òõôàüþöýþ öõ ÃÂÃÂþÃÂüøÃÂþòðÃÂàø POST-÷ðÿÃÂþÃÂ, ÿþôúûÃÂÃÂøòÃÂøÃÂàÃÂõûýõÃÂþü ýð 80-ù ÿþÃÂÃÂ! ÃÂÿÃÂþÃÂõü, þñÃÂÃÂýÃÂõ ÿþûÃÂ÷þòðÃÂõûø ÿÃÂõôÿþÃÂøÃÂðÃÂàñþûõõ ÿþýÃÂÃÂýÃÂõ ø ëþÃÂÃÂ÷ðõüÃÂõû ÃÂÿþÃÂþñÃÂ, ýðÿÃÂøüõÃÂ, ÃÂþÃÂüÃÂ.
ÃÂðú þýø òÃÂóûÃÂôÃÂÃÂ, ôÃÂüðÃÂ, úðöôÃÂù ÷ýðõÃÂ. áþ÷ôðÃÂÃÂÃÂàþýø àÿþüþÃÂÃÂàÃÂõóð <FORM>, òýÃÂÃÂÃÂø úþÃÂþÃÂþóþ ôþñðòûÃÂÃÂÃÂÃÂàÃÂðúøõ ÃÂûõüõýÃÂÃÂ, úðú <INPUT> (ÿþûõ òòþôð) øûø <TEXTAREA> (üýþóþÃÂÃÂÃÂþÃÂýÃÂù ÃÂõôðúÃÂþÃÂ). ÃÂÃÂøü ÃÂûõüõýÃÂðü, õÃÂûø øàôðýýÃÂõ ôþûöýàñÃÂÃÂàÿõÃÂõôðýàýð ÃÂõÃÂòõÃÂ, ÿÃÂøÃÂòðøòðÃÂÃÂÃÂàøüõýð àÿþüþÃÂÃÂàðÃÂÃÂøñÃÂÃÂð name. ÃÂðÃÂðûÃÂýþõ ÷ýðÃÂõýøõ ÷ðôðõÃÂÃÂàÿðÃÂðüõÃÂÃÂþü value ø ò ôðûÃÂýõùÃÂõü ôûàëÃÂõôðúÃÂøÃÂÃÂõüÃÂàû ÿþûõù üþöõàñÃÂÃÂàø÷üõýõýþ ÿþûÃÂ÷þòðÃÂõûõü. ÃÂþóôð ÿþûÃÂ÷þòðÃÂõûàýðöøüðõàúýþÿúàëÃÂÃÂÿÃÂðòøÃÂÃÂû (ýðôÿøÃÂàýð ýõù, ò ÿÃÂøýÃÂøÿõ, üþöýþ ø÷üõýøÃÂÃÂ), ÃÂþ ñÃÂðÃÂ÷õàþñÃÂõôøýÃÂõàòÃÂõ ôðýýÃÂõ ÿþûõù ò ÿðÃÂàname=value, ÃÂð÷ôõûÃÂàøàÃÂøüòþûþü &. ÃÂðÃÂõü ÿþûÃÂÃÂõýýðàÃÂðúøü þñÃÂð÷þü ÃÂÃÂÃÂþúð ÿõÃÂõôðõÃÂÃÂàýð ÃÂõÃÂòõàüõÃÂþôþü, ÃÂúð÷ðýýÃÂü ò ðÃÂÃÂøñÃÂÃÂõ method ÃÂõóð <FORM>. ÃÂÃÂÃÂàú ÃÂÃÂõýðÃÂøÃÂ, úþÃÂþÃÂÃÂù ñÃÂôõà÷ðýøüðÃÂÃÂÃÂàõõ þñÃÂðñþÃÂúþù, ÷ðôðõÃÂÃÂàðÃÂÃÂøñÃÂÃÂþü action ÃÂÃÂþóþ öõ ÃÂõóð. ÃÂÃÂûø action ýõ ÷ðôðý, ÃÂþ ôðýýÃÂõ ÿõÃÂõôðÃÂÃÂÃÂàÃÂðùûÃÂ, ÃÂÃÂþÃÂüøÃÂþòðòÃÂõüàÃÂõúÃÂÃÂÃÂàÃÂÃÂÃÂðýøÃÂúÃÂ.
ÃÂÃÂûø ÃÂÃÂþ-ÃÂþ ýõ ÃÂþòÃÂõü ÿþýÃÂÃÂýþ, þñÃÂðÃÂøÃÂõÃÂàú úþôàÃÂð÷ÃÂðñðÃÂÃÂòðõüþù óþÃÂÃÂõòþù úýøóø, úþÃÂþÃÂÃÂù ÿÃÂøòõôõý ýøöõ.
ÃÂðàÃÂÿðÃÂøÃÂõûàâ üþôÃÂûàcgi
ÃÂþ÷òÃÂðÃÂðõüÃÂàú þñÃÂðñþÃÂúõ òÃÂõóþ ÃÂÃÂþóþ ôþñÃÂð, úþÃÂþÃÂþõ ÃÂþÃÂýø ÿþûÃÂ÷þòðÃÂõûõù ÃÂöõ óþÃÂþòàþñÃÂÃÂÃÂøÃÂàýð ýðàñõôýÃÂù ÃÂÃÂõýðÃÂøù. ÃÂàÃÂõÃÂøûø òþÃÂÿþûÃÂ÷þòðÃÂÃÂÃÂàÃÂÃÂðýôðÃÂÃÂýÃÂüø ÃÂÃÂõôÃÂÃÂòðüø Python, ø ÷ôõÃÂàòÃÂõ ôõùÃÂÃÂòøÃÂõûÃÂýþ þÃÂõýàÿÃÂþÃÂÃÂþ â øüÿþÃÂÃÂøÃÂÃÂùÃÂõ üþôÃÂûàcgi ø, ÃÂþ÷ôðò þñÃÂõúàúûðÃÂÃÂð FieldStorage, òàÿþûÃÂÃÂøÃÂõ ÃÂõÃÂõ÷ ýõóþ ôþÃÂÃÂÃÂÿ úþ òÃÂõü ôðýýÃÂü, ÿõÃÂõôðýýÃÂü ÿþûÃÂ÷þòðÃÂõûõü, ýõ÷ðòøÃÂøüþ þàøÃÂÿþûÃÂ÷ÃÂõüþóþ üõÃÂþôð:
import cgi data = cgi.FieldStorage() for entry in data.keys(): print 'ÃÂõÃÂõüõýýðà%s øüõõà÷ýðÃÂõýøõ %s' % (entry, data[entry].value)
ÃÂÃÂûø òðü ýÃÂöýþ ÿþûÃÂÃÂøÃÂà÷ýðÃÂõýøõ þÿÃÂõôõûõýýþóþ ÿþûÃÂ, ÃÂÃÂþ ôõûðõÃÂÃÂàÃÂðú:
field = data['field'].value
ÃÂþüøüþ ÿþûÃÂ÷þòðÃÂõûÃÂÃÂúøàôðýýÃÂà, þñÃÂõúàúûðÃÂÃÂð FieldStorage ÃÂþôõÃÂöøàøýÃÂþÃÂüðÃÂøàø þ ÿþûÃÂà÷ðóþûþòúð (ò ýðÃÂõü ÿÃÂøüõÃÂõ øàüþöýþ ÿþûÃÂÃÂøÃÂàø÷ ÃÂûþòðÃÂàdata.headers). MIME-ÃÂøÿ ôðýýÃÂà(ÿõÃÂõôðòðõüÃÂù ÿþûõü ÷ðóþûþòúð Content-Type) üþöýþ ÿþûÃÂÃÂøÃÂàø÷ ðÃÂÃÂøñÃÂÃÂð data.type. çõÃÂõ÷ ÃÂÃÂþàöõ þñÃÂõúàüþöõàñÃÂÃÂàòÃÂÿþûýõýð ø ÷ðóÃÂÃÂ÷úð ÃÂðùûð.
á ÿþüþÃÂÃÂàüõÃÂþôþò keys() ø has_key() üþöýþ òÃÂÿþûýÃÂÃÂàþñÃÂðñþÃÂúàÿþûÃÂÃÂõýýÃÂàôðýýÃÂàò ÃÂøúûõ ø ÿÃÂþòõÃÂÃÂÃÂàýðûøÃÂøõ ÃÂþù øûø øýþù ÿõÃÂõüõýýþù. ÃÂÃÂÃÂðÃÂø óþòþÃÂÃÂ, ÿÃÂþòõÃÂÃÂÃÂàýðûøÃÂøõ ÿõÃÂõüõýýþù òþ òàþôýÃÂàôðýýÃÂà, ÿÃÂõöôõ ÃÂõü ÿÃÂøÃÂÃÂÃÂÿðÃÂàú øàþñÃÂðñþÃÂúõ, ýÃÂöýþ ýõÿÃÂõüõýýþ â òõôà÷ðÿÃÂþàÃÂþÃÂüøÃÂÃÂõÃÂÃÂàúûøõýÃÂþü, ð úÃÂþ ÷ýðõÃÂ, ÃÂÃÂþ àýõóþ ýð ÃÂüõ?
ÃÂð÷øÃÂÃÂõü ôðýýÃÂõ
ÃÂÃÂðú, ÿþûÃÂÃÂðÃÂàôðýýÃÂõ þàúûøõýÃÂð üàýðÃÂÃÂøûøÃÂÃÂ. ÃÂÃÂÿÃÂðòûÃÂÃÂàÃÂþöõ ÃÂüõõü. ÃÂÃÂÃÂðûþÃÂàÿÃÂøôÃÂüðÃÂÃÂ, úðú ÃÂÃÂø ôðýýÃÂõ ûÃÂÃÂÃÂõ òÃÂõóþ àÃÂðýøÃÂÃÂ. ÃÂþýõÃÂýþ, ôûàýõÃÂûþöýþù óþÃÂÃÂõòþù úýøóø àýõñþûÃÂÃÂþù ýðóÃÂÃÂ÷úþù òÿþûýõ àòðÃÂøûþ ñàø ÃÂõúÃÂÃÂþòÃÂàÃÂðùûþò. ÃÂÃÂðòôð, ÃÂðü õÃÂÃÂàÃÂòþø ÃÂûþöýþÃÂÃÂø â õÃÂûø ÃÂÃÂð÷àÿÃÂÃÂàÃÂõûþòõú ÷ðàþÃÂÃÂàòÃÂÃÂúð÷ðÃÂàÃÂòþõ üýõýøõ þ òðÃÂõù úÃÂÃÂÃÂõùÃÂõù ôþüðÃÂýõù ÃÂÃÂÃÂðýøÃÂúõ, ÃÂþ ÃÂÃÂõýðÃÂøàÿÃÂøôõÃÂÃÂàúðúøü-ÃÂþ þñÃÂð÷þü ÃÂõóÃÂûøÃÂþòðÃÂàôþÃÂÃÂÃÂÿ ú ÃÂðùûÃÂ-àÃÂðýøûøÃÂà(úðú üøýøüÃÂü, þñÃÂðñðÃÂÃÂòðÃÂàÃÂøÃÂÃÂðÃÂøÃÂ, õÃÂûø ÃÂðùû ÃÂöõ þÃÂúÃÂÃÂàýð ÷ðÿøÃÂàôÃÂÃÂóøü ÃÂú÷õüÿûÃÂÃÂþü ÃÂÃÂõýðÃÂøÃÂ). ÃÂþ ÷ðÃÂõü ýðü òÃÂõ ÃÂÃÂø óþûþòýÃÂõ ñþûø? ÃÂÃÂûø üàÃÂðú ûþòúþ þÃÂòõÃÂÃÂõûøÃÂàþàýõþñàþôøüþÃÂÃÂø òÃÂÃÂÃÂýÃÂàÃÂð÷ñøÃÂðÃÂàHTTP-÷ðÿÃÂþÃÂÃÂ, ÃÂþ ýõÃÂöõûø ýõ ýðùôõü ÃÂÃÂþ-ÃÂþ ÿþôàþôÃÂÃÂõõ ýð ÃÂÃÂþàÃÂð÷?
ÃÂþýõÃÂýþ, ýðùôõü! àÃÂÃÂþ ëÃÂÃÂþ-ÃÂþû ýð÷ÃÂòðõÃÂÃÂàÃÂøÃÂÃÂõüþù ÃÂÿÃÂðòûõýøàñð÷ðüø ôðýýÃÂà(ò ÿÃÂþÃÂÃÂþÃÂõÃÂÃÂõ â áãÃÂÃÂ). âõÿõÃÂàýðÃÂõ ôõûþ â þÃÂÿÃÂðòøÃÂà÷ðÿÃÂþàø ÿþûÃÂÃÂøÃÂàþÃÂòõÃÂ. ÃÂÃÂõ þÃÂÃÂðûÃÂýþõ â ÃÂöõ ýõ ýðÃÂð ÷ðñþÃÂð.
ÃÂûàÃÂÃÂþóþ ÿÃÂøüõÃÂð àòÃÂñÃÂðû ò úðÃÂõÃÂÃÂòõ ëþÃÂòõÃÂÃÂÃÂòõýýþóþû ÷ð àÃÂðýõýøõ ôðýýÃÂàÃÂõÃÂòõàñð÷ ôðýýÃÂàPostgreSQL. ÃÂþÃÂúþûÃÂúàüàÿøÃÂõü ýàþÃÂõýàÿÃÂþÃÂÃÂÃÂàóþÃÂÃÂõòÃÂàúýøóÃÂ, ÃÂþ ø ÃÂÃÂÃÂÃÂúÃÂÃÂÃÂð ñð÷àñÃÂôõààýðàÃÂûõüõýÃÂðÃÂýþù â þôýð ÃÂðñûøÃÂð àÃÂÃÂõüàÿþûÃÂüø: òÃÂõüàÿÃÂñûøúðÃÂøø ÃÂþþñÃÂõýøÃÂ, øüàðòÃÂþÃÂð ø, ÃÂþñÃÂÃÂòõýýþ, ÃÂðüþ ÃÂþþñÃÂõýøõ:
admin@toshiba:~$ psql Welcome to psql 8.1.4, the PostgreSQL interactive terminal. guestbook=# create user "www-data" nocreatedb nocreateuser; CREATE ROLE admin=# create database guestbook with owner "www-data"; CREATE DATABASE admin=# \connect guestbook ÃÂàÿþôÃÂþõôøýøûøÃÂàú ñð÷õ ôðýýÃÂà"guestbook". guestbook=# create table guestbook ( guestbook(# datum timestamp, author varchar, message varchar); CREATE TABLE guestbook=# alter table guestbook owner to "www-data"; ALTER TABLE guestbook=# \q admin@toshiba:~$
ÃÂþöðûÃÂù, õôøýÃÂÃÂòõýýþõ, ÃÂÃÂþ ÷ôõÃÂàýÃÂöýþ ÿþÃÂÃÂýøÃÂÃÂ, ÃÂÃÂþ ÿþÃÂõüàñð÷õ ø ÃÂðñûøÃÂõ üàýð÷ýðÃÂøûø òûðôõûÃÂÃÂõü ÿþûÃÂ÷þòðÃÂõûàwww-data. ÃÂÃÂþÃÂÃÂþ ú ýøü ñÃÂôõàþñÃÂðÃÂðÃÂÃÂÃÂàcgi-ÃÂÃÂõýðÃÂøù, ÃÂðñþÃÂðÃÂÃÂøù àÿÃÂðòðüø HTTP-ÃÂõÃÂòõÃÂð Apache, úþÃÂþÃÂÃÂù, ò ÃÂòþàþÃÂõÃÂõôÃÂ, øÃÂÿþûýÃÂõÃÂÃÂàþàøüõýø ôðýýþóþ ÿþûÃÂ÷þòðÃÂõûà[ò òðÃÂõü ôøÃÂÃÂÃÂøñÃÂÃÂøòõ þý üþöõàýð÷òðÃÂÃÂÃÂàÿþ-ôÃÂÃÂóþüÃÂ, â ÿÃÂøü. ÃÂõô.]. àPostgreSQL ÿþ ÃÂüþûÃÂðýøàÃÂÃÂõñÃÂõÃÂ, ÃÂÃÂþñàøüàÿþûÃÂ÷þòðÃÂõûàò ÃÂàÃÂþòÿðôðûþ àõóþ ÃÂøÃÂÃÂõüýÃÂü øüõýõü. ÃÂýõ ÃÂÃÂþ úðöõÃÂÃÂàôþÃÂÃÂðÃÂþÃÂýþ ÃÂôþñýÃÂü, àþÃÂàòÃÂ, úþýõÃÂýþ, üþöõÃÂõ ÿþÃÂÃÂÃÂÿøÃÂàÿþ-ÃÂòþõüÃÂ.
DB API ýð ÃÂÃÂÃÂðöõ ÃÂýøÃÂøúðÃÂøø
ÃÂÃÂÃÂðûþÃÂàÃÂð÷þñÃÂðÃÂÃÂÃÂÃÂ, úðú öõ Python ò÷ðøüþôõùÃÂÃÂòÃÂõààñð÷ðüø ôðýýÃÂà. ÃÂûàÃÂÃÂþóþ Python ÿÃÂõôþÃÂÃÂðòûÃÂõàDB API â ÃÂÿõÃÂøðûÃÂýÃÂù øýÃÂõÃÂÃÂõùÃÂ, ÃÂýøÃÂøÃÂøÃÂÃÂÃÂÃÂøù ýðñþàüõÃÂþôþò, úþÃÂþÃÂÃÂõ ñÃÂôÃÂàþôøýðúþòþ ÃÂðñþÃÂðÃÂàýõ÷ðòøÃÂøüþ þàÃÂþóþ, àúðúþù áãÃÂàüàò÷ðøüþôõùÃÂÃÂòÃÂõü. ÃÂûàÃÂðñþÃÂààPostgreSQL ýðü ÿþýðôþñøÃÂÃÂàüþôÃÂûàPyPgSQL (ò ÃÂÃÂðýôðÃÂÃÂýþù ÿþÃÂÃÂðòúõ õóþ üþöõàýõ þúð÷ðÃÂÃÂÃÂÃÂ, ýþ òðàüõýõôöõàÿðúõÃÂþò ýðòõÃÂýÃÂúð ñÃÂôõàò úÃÂÃÂÃÂõ, úðú õóþ ÃÂÃÂÃÂðýþòøÃÂÃÂ; úÃÂÃÂðÃÂø, ÃÂÃÂþ ýõ õôøýÃÂÃÂòõýýÃÂù üþôÃÂûàâ àòðÃÂ, òþ÷üþöýþ, ñÃÂôõàPyGreSQL, úþÃÂþÃÂÃÂù ÃÂðñþÃÂðõàýøÃÂÃÂÃÂàýø àÃÂöõ ø àÃÂõüø öõ ÃÂðüÃÂüø üõÃÂþôðüø).
DB API þÿÃÂõôõûÃÂõàÃÂÃÂðýôðÃÂÃÂýÃÂõ üõÃÂþôàÃÂðñþÃÂààñð÷ðüø ôðýýÃÂà, ÃÂðú ÃÂÃÂþ, úðúþù ñàüþôÃÂûàòàýø ÷ðóÃÂÃÂ÷øûø ø àúðúþù ñàáãÃÂàýø ÃÂðñþÃÂðûø (ñÃÂôàÃÂþ MySQL, PostgreSQL, SQLite øûø ÃÂÃÂþ-ÃÂþ õÃÂõ), üõýÃÂÃÂÃÂÃÂàñÃÂôõàÃÂþûÃÂúþ øüàüþôÃÂûÃÂ. ÃÂûðòýþõ, ÃÂÃÂþñàøÃÂÿþûÃÂ÷ÃÂõüÃÂù üþôÃÂûàÃÂþþÃÂòõÃÂÃÂÃÂòþòðû DB API. àðÃÂÃÂüþÃÂÃÂøü úþÃÂþÃÂúþ þÃÂýþòýÃÂõ üõÃÂþôÃÂ:
conn = connect(dsn='localhost', user='admin', password='superparol', database='mydb')
âðú þÃÂÃÂÃÂõÃÂÃÂòûÃÂõÃÂÃÂàÿþôúûÃÂÃÂõýøõ ú ñð÷õ. à÷ðòøÃÂøüþÃÂÃÂø þàÃÂøÃÂÃÂðÃÂøø, òðü üþöõàÿþÃÂÃÂõñþòðÃÂÃÂÃÂàÃÂúð÷ðÃÂàÃÂþûÃÂúþ ýÃÂöýÃÂõ ÿðÃÂðüõÃÂÃÂà(ýðÿÃÂøüõÃÂ, øüààþÃÂÃÂð 'localhost' ÿþôÃÂð÷ÃÂüõòðõÃÂÃÂàÿþ ÃÂüþûÃÂðýøÃÂ).
cur = conn.cursor()
ÃÂÃÂÃÂÃÂþÃÂàÿþôôõÃÂöøòðÃÂÃÂÃÂàôðûõúþ ýõ òÃÂõüø áãÃÂÃÂ, ýþ ôûàþñÃÂýþÃÂÃÂø ò DB API þýø òòõôõýàø, ò ÃÂûÃÂÃÂðõ ýõþñàþôøüþÃÂÃÂø, ôþûöýàÃÂüÃÂûøÃÂþòðÃÂÃÂÃÂàüþôÃÂûÃÂüø ÃÂþÿÃÂÃÂöõýøàøÃÂúÃÂÃÂÃÂÃÂòõýýþ. âðú ÃÂÃÂþ ýõ ÷ðñÃÂòðùÃÂõ þÃÂÿÃÂðòûÃÂÃÂàòÃÂõ òðÃÂø ÷ðÿÃÂþÃÂàÃÂõÃÂõ÷ úÃÂÃÂÃÂþÃÂ.
cur.execute('''SELECT * FROM mytable''')
âðú òÃÂÿþûýÃÂõÃÂÃÂàSQL-÷ðÿÃÂþÃÂ. ÃÂÃÂûø ò ÃÂÃÂÃÂþúõ ÷ðÿÃÂþÃÂð øÃÂÿþûÃÂ÷ÃÂÃÂÃÂÃÂà÷ýðúþüõÃÂÃÂð %s, ÃÂþ òÃÂþÃÂÃÂü ÿðÃÂðüõÃÂÃÂþü ÿõÃÂõôðõÃÂÃÂàÃÂÿøÃÂþú ÿõÃÂõüõýýÃÂà-÷ýðÃÂõýøù, ÿÃÂøÃÂõü ò SQL-÷ðÿÃÂþÃÂõ ÷ýðúþüõÃÂÃÂð ýõ ÃÂÃÂõñÃÂõÃÂÃÂàþúÃÂÃÂöðÃÂàðÿþÃÂÃÂÃÂþÃÂðüø â üþôÃÂûàÃÂôõûðõàÃÂÃÂþ ÃÂðüþÃÂÃÂþÃÂÃÂõûÃÂýþ ò ÷ðòøÃÂøüþÃÂÃÂø þàÃÂøÿð ÿõÃÂõüõýýþù.
cur.fetchall()
ÃÂþ÷òÃÂðÃÂðõàôòÃÂüõÃÂýÃÂù ÃÂÿøÃÂþú (ÃÂÃÂÃÂþúø â ÿþûÃÂ) ÿþûÃÂÃÂõýýÃÂàþàáãÃÂàôðýýÃÂà. áÃÂÃÂõÃÂÃÂòÃÂÃÂàø ôÃÂÃÂóøõ üõÃÂþôÃÂ, þ÷ýðúþüøÃÂÃÂÃÂààúþÃÂþÃÂÃÂüø òàÃÂüþöõÃÂõ ò ôþúÃÂüõýÃÂðÃÂøø øûø àÿþüþÃÂÃÂà÷ýðúþüþù òðü ÃÂÃÂýúÃÂøø dir() ôð ÿðÃÂÃÂ-ÃÂÃÂþùúø ýõÃÂûþöýÃÂàÃÂúÃÂÿõÃÂøüõýÃÂþò.
ÃÂðúÃÂõÿûÃÂõü ýð ÿÃÂðúÃÂøúõ
ÃÂõÃÂõùôõü ú ÃÂðÃÂÃÂüþÃÂÃÂõýøàýðÃÂõóþ ÿÃÂøüõÃÂð. ÃÂðÃÂýõü ÃÂÃÂðýôðÃÂÃÂýþ â ÃÂúðöõü úþôøÃÂþòúÃÂ, ÿþôúûÃÂÃÂøü ýÃÂöýÃÂõ üþôÃÂûø:
#!/usr/bin/Python # -*- coding: utf-8 -*- import PyPgSQL.PgSQL as pg import cgi
ÃÂðûõõ, þÿÃÂõôõûøü ôòõ ÃÂÃÂýúÃÂøø. ÃÂõÃÂòðàñÃÂôõàþÃÂòõÃÂðÃÂà÷ð ôþñðòûõýøõ ýþòþóþ ÃÂþþñÃÂõýøàò ñð÷ÃÂ:
def addMessage(author, message): db = pg.connect(database="guestbook") c = db.cursor() c.execute("""INSERT INTO guestbook (datum, author, message) VALUES ('now', %s, %s);""", (author, message)) c.close() db.commit() db.close() print "Content-Type: text/html" print "Location: ?#form\n"
ÃÂðú òøôøÃÂõ, òÃÂõ þÃÂõýàôðöõ ûþóøÃÂýþ: ÃÂÃÂÃÂðýðòûøòðõü ÃÂþõôøýõýøõ àÃÂà(ÿþÃÂúþûÃÂúàò ýðÃÂõü ÃÂûÃÂÃÂðõ ÿþôúûÃÂÃÂõýøõ òÃÂÿþûýÃÂõÃÂÃÂààøüõýõü ÃÂõúÃÂÃÂõóþ ÃÂøÃÂÃÂõüýþóþ ÿþûÃÂ÷þòðÃÂõûÃÂ, ÃÂþ ôþÃÂÃÂðÃÂþÃÂýþ ÃÂúð÷ðÃÂàÃÂþûÃÂúþ øüàñð÷ÃÂ), ÃÂþ÷ôðõü úÃÂÃÂÃÂþà(ò PostgreSQL þýø ýõ ÿÃÂøüõýÃÂÃÂÃÂÃÂÃÂ, ýþ þýø ÃÂüÃÂûøÃÂÃÂÃÂÃÂÃÂàúðöôÃÂü üþôÃÂûõü, ÿÃÂõÃÂõýôÃÂÃÂÃÂøü ýð ÃÂþþÃÂòõÃÂÃÂÃÂòøõ DB API), òÃÂÿþûýÃÂõÃÂÃÂà÷ðÿÃÂþÃÂ, ÷ðúÃÂÃÂòðõÃÂÃÂàúÃÂÃÂÃÂþÃÂ, ÃÂøúÃÂøÃÂÃÂÃÂÃÂÃÂàø÷üõýõýøà(PostgreSQL øÃÂÿþûÃÂ÷ÃÂõàÃÂÃÂðý÷ðúÃÂøø, ÿþÃÂÃÂþüàòÃÂÿþûýõýøõ üõÃÂþôð commit() þñÃÂ÷ðÃÂõûÃÂýþ, øýðÃÂõ òðÃÂø ø÷üõýõýøàýõ ñÃÂôÃÂàÃÂþàÃÂðýõýÃÂ), ø, ýðúþýõÃÂ, ÷ðúÃÂÃÂòðõü ÃÂðüþ ÃÂþõôøýõýøõ àñð÷þù. àÿþûõ datum ÷ðýþÃÂøü ÷ýðÃÂõýøõ òÃÂÃÂÃÂþõýýþù ÿõÃÂõüõýýþù PostgreSQL â now, úþÃÂþÃÂðàúðöôÃÂù ÃÂð÷ ÷ðüõýÃÂõÃÂÃÂàÃÂõúÃÂÃÂøü ÷ýðÃÂõýøõü ôðÃÂàø òÃÂõüõýø.
ÃÂàø ÿõÃÂðÃÂà÷ðóþûþòúð ëLocationû òÃÂÿþûýÃÂõÃÂÃÂàôûàÃÂþóþ, ÃÂÃÂþñàÿõÃÂõýðÿÃÂðòøÃÂàÿþûÃÂ÷þòðÃÂõûàýð ÃÂÃÂþàöõ ÃÂÃÂõýðÃÂøù, ýþ ÃÂöõ ñõ÷ ÿðÃÂðüõÃÂÃÂþò â üàöõ ôþûöýàÿþúð÷ðÃÂàúûøõýÃÂÃÂ, ÃÂÃÂþ þý ýð ÃÂðüþü ôõûõ òòõû? (ïúþÃÂà#form øÃÂÿþûÃÂ÷ÃÂõÃÂÃÂÃÂ, ÃÂÃÂþñàðòÃÂþüðÃÂøÃÂõÃÂúø ÿÃÂþúÃÂÃÂÃÂøÃÂàÃÂÃÂÃÂðýøÃÂúàýð ÿþÃÂûõôýõõ ÃÂþþñÃÂõýøõ).
ÃÂÃÂþÃÂðàÃÂÃÂýúÃÂøàñÃÂôõàþÃÂòõÃÂðÃÂà÷ð òÃÂòþô ýð ÃÂúÃÂðý ÃÂöõ þÃÂÃÂðòûõýýÃÂàò úýøóõ ÷ðÿøÃÂõù, ð ÃÂðúöõ ÷ð ÃÂþÃÂüÃÂ, àÿþüþÃÂÃÂàúþÃÂþÃÂþù üþöýþ ñÃÂôõàôþñðòøÃÂàø ÃÂòþõ òÃÂÃÂúð÷ÃÂòðýøõ:
def showGB(): db = pg.connect(database="guestbook") c = db.cursor() c.execute("""SELECT datum, author, message FROM guestbook ORDER BY datum;""") res = c.fetchall() c.close() db.close()
àÃÂÃÂþü ÃÂÃÂðóüõýÃÂõ üàòÃÂñøÃÂðõü òÃÂõ ÃÂÃÂÃÂþúø ø÷ ýðÃÂõù ÃÂðñûøÃÂàôðýýÃÂà, ÃÂþÃÂÃÂøÃÂÃÂàøàÿþ ôðÃÂõ. àõ÷ÃÂûÃÂÃÂðàÃÂþàÃÂðýÃÂõÃÂÃÂàò ÿõÃÂõüõýýþù res, àúþÃÂþÃÂþù ø ñÃÂôõü ÃÂðñþÃÂðÃÂÃÂ. âõÿõÃÂàþÃÂÃÂðûþÃÂàûøÃÂàðúúÃÂÃÂðÃÂýõýÃÂúþ ÃÂð÷ûþöøÃÂàýðÃÂø ôðýýÃÂõ ÿþ ÃÂðñûøÃÂúðü ø òÃÂòõÃÂÃÂø øàýð ÃÂúÃÂðý:
print "Content-Type: text/html\n" print "<H1 style='color:#7777FF'><U>ÃÂõûÃÂúðü ú ýðü ò óþÃÂÃÂø!</U></H1>" for item in res: print """<TABLE width='90%%'> <TR><TD><SMALL>âþòðÃÂøà<B>%s</B> ÿþòõôðûýðü ÃÂûõôÃÂÃÂÃÂõõ:</SMALL> <TD align='right'><SMALL>%s</SMALL> <TR><TD style='background-color:#DDDDFF' colspan='2'>%s </TABLE>""" % (item[1], str(item[0])[:19], item[2]) print "<HR><A name='form'><H3>ÃÂÃÂøÃÂþõôøýÃÂùÃÂõÃÂàú ôøÃÂúÃÂÃÂÃÂøø:</H3>" print """<FORM method='GET'> ÃÂðÃÂõ øüÃÂ: <INPUT type='text' name='author'><BR> çÃÂþ òàôÃÂüðõÃÂõ ÿþ ÃÂÃÂþüàÿþòþôÃÂ:<BR> <TEXTAREA name='message' rows='5' cols='80'></TEXTAREA><BR> <INPUT type='submit' value='ÃÂÃÂÿÃÂðòøÃÂÃÂ'> </FORM>"""
áüÃÂÃÂû úþýÃÂÃÂÃÂÃÂúÃÂøø str(item[0])[:19] ÷ðúûÃÂÃÂðõÃÂÃÂàò ÃÂþü, ÃÂÃÂþñàò ÃÂÃÂÃÂþúõ òÃÂõüõýø þÃÂÃÂõÃÂàýõýÃÂöýÃÂõ ýðü üøûûøÃÂõúÃÂýôÃÂ, úþÃÂþÃÂÃÂõ ÃÂþàÃÂðýÃÂÃÂÃÂÃÂàò ÿþûõ ÃÂøÿð timestamp. ÃÂþÃÂûõ òÃÂõàþÿÃÂñûøúþòðýýÃÂàÃÂþþñÃÂõýøù òÃÂòþôøü ÃÂþÃÂüàôþñðòûõýøàýþòþóþ, ÃÂÃÂþñàúðöôÃÂù üþó ÿÃÂøÃÂþõôøýøÃÂÃÂÃÂàú ýðÃÂõù ôøÃÂúÃÂÃÂÃÂøø. ÃÂÃÂÃÂðÃÂø, ò ÃÂõóõ <FORM> üàýõ ÃÂúð÷ðûø ÿðÃÂðüõÃÂàaction, ÿþÃÂúþûÃÂúàôðýýÃÂõ ñÃÂôÃÂàÿõÃÂõôðòðÃÂÃÂÃÂàýð þñÃÂðñþÃÂúàÃÂÃÂþüàöõ ÃÂÃÂõýðÃÂøà(ñûðóþôðÃÂàÃÂõüàøüàÃÂÃÂõýðÃÂøàüþöýþ ÿÃÂøÃÂòþøÃÂàûÃÂñþõ). ÃÂðúþýõÃÂ, ÿþÃÂûõôýøù ÃÂÃÂðóüõýÃÂ:
form = cgi.FieldStorage() if form.has_key("message") and form.has_key("author"): author = cgi.escape(form["author"].value) message = cgi.escape(form["message"].value) message = message.replace("\n", "<BR>") addMessage(author, message) else: showGB()
áþ÷ôðõü FieldStorage-þñÃÂõúÃÂ, ø õÃÂûø ò ýõü õÃÂÃÂà÷ðÿþûýõýýÃÂõ ÿþûàmessage ø author (ÃÂþ õÃÂÃÂà÷ðÿÃÂþàñÃÂû ÃÂÃÂþÃÂüøÃÂþòðý ø÷ ÷ðÿþûýõýýþù ÿþûÃÂ÷þòðÃÂõûõü ÃÂþÃÂüÃÂ), ÃÂþ, ýõüýþöúþ øàþñÃÂðñþÃÂðò (ÃÂÃÂýúÃÂøàcgi.escape() ÷ðüõýÃÂõàòÃÂõ ëýõñûðóþýðôõöýÃÂõû ÃÂøüòþûàâ ýðÿÃÂøüõÃÂ, < â øàÃÂÃÂðýôðÃÂÃÂýÃÂüø SGML-ÃÂÃÂÃÂýþÃÂÃÂÃÂüø, ò ôðýýþü ÃÂûÃÂÃÂðõ â <), ÿõÃÂõôðõü ÃÂÃÂýúÃÂøø addMessage(). ÃÂñÃÂðñþÃÂúð ýÃÂöýð ôûàÃÂþóþ, ÃÂÃÂþñà÷ûþÃÂüÃÂÃÂûõýýøú ýõ üþó òòõÃÂÃÂø ò ÿþûõ ÃÂþþñÃÂõýøàøûø øüõýø ðòÃÂþÃÂð ÃÂÃÂþ-ýøñÃÂôàÃÂðúþõ:
<SCRIPT>alert('ÃÂð ÿþÃÂûø òàòÃÂõ!');</SCRIPT>
àÃÂûþòÃÂ, ÿÃÂõýõñÃÂõóðÃÂàÿÃÂþòõÃÂúþù òòõôõýýÃÂàôðýýÃÂàýø ò úþõü ÃÂûÃÂÃÂðõ ýõûÃÂ÷ÃÂ. ÃÂðùôøÃÂõ úðú-ýøñÃÂôàýð securitylab.ru ø ÿþÃÂüþÃÂÃÂøÃÂõ, ÃÂúþûÃÂúþ ÃÂÃÂ÷òøüþÃÂÃÂõù ÃÂøÿð ëXSSû þñýðÃÂÃÂöøòðõÃÂÃÂàúðöôÃÂù üõÃÂÃÂÃÂ! âðú ÃÂÃÂþ ÃÂÃÂÃÂúø ÃÂÃÂÃÂúðüø, ýþ ÿþÃÂûõôÃÂÃÂòøàüþóÃÂàñÃÂÃÂàþÃÂõýàÃÂõÃÂÃÂõ÷ýÃÂüø.
ÃÂÃÂôð öõ ýðü ÃÂõÿõÃÂàøôÃÂø?
ÃÂÃÂðú, ÃÂÃÂþ-ÃÂþ òÿþûýõ ÃÂðñþÃÂþÃÂÿþÃÂþñýþõ àýðàõÃÂÃÂà(ÃÂü. ÃÂøÃÂÃÂýþú). ÃÂþ úðú òàüþöõàôþóðôðÃÂÃÂÃÂÃÂ, ýðÃÂð óþÃÂÃÂõòðàþÃÂõýàôðûõúð þàÃÂþòõÃÂÃÂõýÃÂÃÂòð. çÃÂþ õÃÂõ üþöýþ ÃÂôõûðÃÂÃÂ? ÃÂÃÂ, ýðÿÃÂøüõÃÂ, ÃÂð÷ñøÃÂàýð ÃÂÃÂÃÂðýøÃÂÃÂ. ÃÂþúð ÃÂþþñÃÂõýøù ò ýõù ñÃÂôõàýõ ñþûÃÂÃÂõ ôÃÂöøýÃÂ, ÃÂþùôõàø ÃÂðú. àúþóôð øàÃÂøÃÂûþ ôþùôõàôþ ÃÂþÃÂýø, ÃÂþ ÃÂõôúøù ÿþûÃÂ÷þòðÃÂõûàôþöôõÃÂÃÂàþúþýÃÂðýøà÷ðóÃÂÃÂ÷úø òÃÂõàôðýýÃÂà. ÃÂþöýþ ôðÃÂàÿþûÃÂ÷þòðÃÂõûÃÂü òþ÷üþöýþÃÂÃÂàøÃÂÿþûÃÂ÷þòðÃÂàýõúþÃÂþÃÂÃÂõ HTML-ÃÂõóø, ÃÂÃÂþñàøàÃÂþþñÃÂõýøàòÃÂóûÃÂôõûø ñþûõõ úÃÂðÃÂþÃÂýþ. ÃÂþöýþ ôþñðòøÃÂàÃÂüðùûøúþò... àüþöýþ ôðöõ ÃÂôõûðÃÂàüþôÃÂûàðôüøýøÃÂÃÂÃÂøÃÂþòðýøÃÂ, ÿþ÷òþûÃÂÃÂÃÂøù ÃÂõôðúÃÂøÃÂþòðÃÂàøûø ÃÂôðûÃÂÃÂàÃÂþþñÃÂõýøÃÂ, ð ÃÂðúöõ þÃÂòõÃÂðÃÂàýð ýøà. âðú ÃÂÃÂþ ÃÂðñþÃÂàýõÿþÃÂðÃÂÃÂù úÃÂðù. ÃÂõÃÂ÷ðùÃÂõ â ýõ ñÃÂôàòðü üõÃÂðÃÂÃÂ.
ÃÂõúþÃÂþÃÂÃÂõ ÃÂðÃÂÿÃÂþÃÂÃÂÃÂðýÃÂýýÃÂõ MIME-ÃÂøÿÃÂ
MIME-ÃÂøÿ | ÃÂÿøÃÂðýøõ |
---|---|
text/plain | ÃÂÃÂþÃÂÃÂþù ÃÂõúÃÂà|
text/html | HTML-ÃÂÃÂÃÂðýøÃÂð |
image/gif | ÃÂ÷þñÃÂðöõýøõ GIF |
video/mpeg | ÃÂøôõþ-ÃÂðùû ò ÃÂþÃÂüðÃÂõ MPEG |
application/msword | ÃÂþúÃÂüõýàMS Word |