日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python web py官网_python web.py

發布時間:2023/12/10 python 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python web py官网_python web.py 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

web.py

1.安裝:

wget http://webpy.org/static/web.py-0.37.tar.gz

tar?xvfz?web.py-0.37.tar.gz

cd?web.py-0.37

sudo?python?setup.py?install

2.需求:

先說下需求,http://10.75.7.237:8080/?ipaddress=10.75.7.29&count=100?,最終得到這個ip的日志的前100行

3.講解:

#!/usr/bin/python

import web

render = web.template.render(‘templates/‘) 這是告訴你的web展現頁面放在那個位置

urls = (

‘/‘, ‘index‘

)

這是告訴你訪問/路徑時所調用的類是index

class index:

def reset_sigpipe(self):

signal.signal(signal.SIGPIPE,signal.SIG_DFL)

def GET(self):

ip=web.input(ipaddress=None,count=None) ?讓url可以傳輸多個值名為ipaddress和count

print ip[‘ipaddress‘]

print ip[‘count‘]

a=ip[‘ipaddress‘]

address_dict={‘10.13.144.‘:‘bx‘,‘10.73.26.‘:‘tc‘,‘10.75.7.‘:‘yf‘,‘10.67.15.‘:‘yq‘}

aa=a.split(".")

b=aa[0:3]

d=aa[-1]

e=".".join(b)

c=e+"."

address_1=address_dict[c]

f=str(d)

g=address_1+f

time_day=time.strftime(‘%Y-%m-%d‘)

#h_1=subprocess.Popen(‘grep -R %s /data1/saelog/%s/error/‘%(g,time_day),shell=True,preexec_fn=self.reset_sigpipe(),stdout=subprocess.PIPE)

#h=h_1.stdout.read()

h = os.popen(‘grep -R %s /data1/saelog/%s/error/‘ % (g,time_day))

print h

head_list=[]

sum=0

dict={}

head_lines=ip[‘count‘]

print head_lines

if head_lines:

for i in h:

j=i.split(":")[1:]

head_list.append(j)

for kk in head_list:

dict[sum]=head_list[sum]

sum+=1

if sum == int(head_lines):

break;

dict_json=json.dumps(dict)

else:

for i in h:

j=i.split(":")[1:]

head_list.append(j)

for kk in head_list:

dict[sum]=head_list[sum]

sum+=1

dict_json=json.dumps(dict)

print dict_json

return render.index(dict_json) ? ? ? 傳給頁面展示的值

#return "Hello, world!"

if __name__ == "__main__":

app = web.application(urls, globals())

app.run()

templates目錄下

index.html

$def with (name)

$if name:

$name ? ?name為代碼傳過來的值

4.啟動web.py

python test.py ?后面不跟端口默認就是8080

5.訪問http://10.75.7.237:8080/?ipaddress=10.75.7.29&count=100

總結

以上是生活随笔為你收集整理的python web py官网_python web.py的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。