五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

異步加載網(wǎng)頁示例

2023-02-07 15:36 作者:蕪湖小量化  | 我要投稿

1.首先建立工程文件夾project project文件夾下建立statictemplates文件

# 使用的庫?

from?flask?import?Flask,?render_template
from?flask?import?make_response
import?json

# 先準(zhǔn)備異步加載的服務(wù)端app

from?flask?import?Flask,?render_template
from?flask?import?make_response
import?json
app = Flask(__name__)


@app.route('/')
def?index():
? ?return?render_template('test.html')


@app.route('/data')
def?data_():
? ?data = [{'id':?'1',?'name':?'
嘉然',?'href':?'href="https://space.bilibili.com/672328094?spm_id_from=333.337.0.0";'},
? ? ? ? ? ?{'id':?'2',?'name':?'
星瞳',?'href':?'href="https://space.bilibili.com/401315430?spm_id_from=333.337.0.0";'},
? ? ? ? ? ?{'id':?'3',?'name':?'
露米',?'href':?'href="https://space.bilibili.com/2000609327?spm_id_from=333.337.0.0";'}]
? ?response = make_response(json.dumps(data))
? ?return?response


if?__name__ ==?'__main__':
? ?app.run(host='0.0.0.0',?port=8888)

# 準(zhǔn)備異步加載的html網(wǎng)頁

<!DOCTYPE?html>
<html?lang="en">
<head>
? ?<meta?charset="UTF-8">
? ?<title>
異步加載虛擬偶像網(wǎng)頁</title>
? ?<script?src="../static/jquery-3.6.3.js"></script>
</head>
<body?onload="onLoad()">

<h1?style="color:?hotpink;?font-size:26px;?font-family:?'
楷體','Arial',sans-serif">虛擬偶像運(yùn)營</h1>

<ul?id="video_list">

? ?<li?style="color:?plum">perfectworld</li>
? ?<li?style="color:?yellowgreen">tencent</li>
? ?<li?style="color:?cornflowerblue">bytedance</li>

</ul>
<script>

? ?function?onLoad()
? ?{
? ? ? ?$.get("/data", function(result){
? ? ? ? ? ?data?=?JSON.parse(result)
? ? ? ? ? ?for(var?i =?0;?i <?data.length;i++) {
? ? ? ? ? ? ? ?$('#video_list').append('<br>'?+?'<a?'?+?data[i].href?+?'>'?+?data[i].name?+?'</a>'?+?'<br>')
? ? ? ? ? ?}
? ? ? ?});
? ?}

</script>
</body>
</html>

# 分別把文件jquery.js和網(wǎng)頁置于statictemplates文件下

運(yùn)行app程序 輸入地址127.0.0.1:8888

可以發(fā)現(xiàn)網(wǎng)頁是異步加載data數(shù)據(jù)的,有明顯的延時

wwwwwwwwwwwwwwwwwwwwwwwwwww

效果圖預(yù)覽



異步加載網(wǎng)頁示例的評論 (共 條)

分享到微博請遵守國家法律
桐梓县| 财经| 四川省| 阿坝县| 光泽县| 宝应县| 洞头县| 响水县| 余姚市| 桃江县| 贵阳市| 精河县| 长岭县| 修水县| 海安县| 娄烦县| 太仓市| 临城县| 安新县| 涞源县| 盐津县| 南康市| 阳高县| 光泽县| 东明县| 梓潼县| 台南市| 景泰县| 盐边县| 新晃| 江华| 喀什市| 缙云县| 正阳县| 南昌市| 宣城市| 曲周县| 都匀市| 嫩江县| 饶阳县| 延边|