修改apache配置文件如下
<Directory "/usr/local/sae/httpd//htdocs/cgi-bin">
? ? AllowOverride None
? ? Options ExecCGI
? ? Order allow,deny
java cgi。? ? Allow from all
</Directory>
? ? ?AddType text/html .htm .html .py
? ? ?AddHandler cgi-script .cgi .py
編寫hello_get.py,放在/usr/local/sae/httpd/htdocs/cgi-bin/目錄下,賦予權限chmod a+x?hello_get.py
cgi編程、
代碼:
????
#!/usr/bin/python
import cgi
import os
apache?import time
import cStringIO
import json
form = cgi.FieldStorage()
ip=form.getvalue('ip')
python django、head_lines=form.getvalue('head_lines')
print "Content-type: text/html\n\n"
address_dict={'10.13.144.':'bx','10.73.26.':'tc','10.75.7.':'yf','10.67.15.':'yq'}
python怎么讀。a=ip.split(".")
b=a[0:3]
d=a[-1]
e=".".join(b)
c=e+"."
address_1=address_dict[c]
apache nginx,f=str(d)
g=address_1+f
time_day=time.strftime('%Y-%m-%d')
h=os.popen('grep -R %s /data1/saelog/%s/error/'%(g,time_day))
head_list=[]
sum=0
python cgi、dict={}
if head_lines:
? ? ? ? for i in h:
? ? ? ? ? ? ? ? j=i.split(":")[1:]
? ? ? ? ? ? ? ? head_list.append(j)
? ? ? ? for kk in head_list:
Apache poi,? ? ? ? ? ? ? ? dict[sum]=head_list[sum]
? ? ? ? ? ? ? ? sum+=1
? ? ? ? ? ? ? ? if sum == int(head_lines):
? ? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? print dict
? ? ? ? dict_json=json.dumps(dict)
python 3.11。? ? ? ? print dict_json
else:
? ? ? ? for i in h:
? ? ? ? ? ? ? ? j=i.split(":")[1:]
? ? ? ? ? ? ? ? head_list.append(j)
python做web。? ? ? ? for kk in head_list:
? ? ? ? ? ? ? ? dict[sum]=head_list[sum]
? ? ? ? ? ? ? ? sum+=1
? ? ? ? dict_json=json.dumps(dict)
? ? ? ? print dict_json