用flask寫一個圖文直播網(wǎng)頁(六)

最后就只剩下直播首頁了。

首頁布局

關(guān)于布局,這個就看個人喜好了,我是根據(jù)直播客這個平臺的大小做的,定義的盒子大小也是跟直播客差不多。
test.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Refresh" CONTENT="100">
<!--&lt;!&ndash;禁用瀏覽器緩存&ndash;&gt;-->

<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename = 'test/main.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename = 'test/lrtk.css') }}" />
<link rel="stylesheet" href="{{ url_for('static', filename = 'css/test.css') }}">
<title>直播的名字</title>

</head>
<body>
<div class="main">
    <div class="zhibo">
        <div style="position: relative">
                <img src="{{ url_for('static', filename = 'images/11.png') }}" height="200" width="740">
                <div style="position: absolute; left: 10px; top: 50px" id="title">
                    <h2>介紹</h2>
                </div>
        </div>
        <div id="zhuti">
            <div id="zhiding" class="time">置頂</div>
                <article class="message" id="firstMessage">現(xiàn)場直播</article>
        </div>
        <ul id="show">
            {% for i in photo %}
                <li>
                    <div class="patch">
                        <div class="patch_on">
                            <div class="time_info">
                                <strong>{{ i.create_time }}</strong>
                            </div>
                            <div class="center">
                                <img src="{{ url_for('static', filename = 'image/' + i.picture_path) }}" height="446" width="594" class="center_img">
                                <p>{{ i.content }}</p>
                            </div>
                        </div>
                    </div>
                </li>
                <p>{% endfor %}</p>
        </ul>
        <div class="qidai">內(nèi)容已經(jīng)加載完畢,敬請期待更多內(nèi)容</div>
    </div>
</div>
<script type="text/javascript" src="{{ url_for('static', filename = 
'test/jquery.min.js') }}"></script>
<script type="text/javascript" src="{{ url_for('static', filename = 'test/jquery.imgbox.pack.js') }}"></script>

{#<script type="text/javascript" src="{{ url_for('static', filename = 'test/jquery-3.2.1.js') }}"></script>#}
<script type="text/javascript" src="{{ url_for('static', filename = 'test/test.js') }}"></script>

<!--foot開始-->
<div id="foot" >
<div>
    <a href=# rel="nofollow">關(guān)于我們</a>|<a
     href=#>實驗室微博</a>|<a
     href=#>實驗室官網(wǎng)</a>
    <br/>
    "DROPS攻防實驗室-安全研發(fā)小組版權(quán)所有"
</div>
</div>
</body>
<script>

</script>
</html>

這里用到了一些前端的js文件,是一些同學(xué)幫我弄得,本來他給我寫了一些json代碼,無奈wo太笨了,json一時半會沒學(xué)會,也就用了那種把圖片信息存儲進數(shù)據(jù)庫的笨辦法 o(TωT)o ,好了,下面再貼上直播主頁的功能代碼吧。

sc.py

# 直播首頁
@app.route('/')
def test():
photo_all = Article.query.order_by('-create_time').all()
content = {
    'photo': photo_all      # 獲取所有數(shù)據(jù)
}
return render_template('test.html', **content)

到這里就沒什么要說的了,代碼也不詳細一一解釋了,我覺得,自己慢慢探索出代碼的意義會更好。
總體看 哇!寫的很少,代碼很多,果然我還是好懶哦(?_?)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Android 自定義View的各種姿勢1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 179,115評論 25 709
  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,593評論 19 139
  • 昨天下午和現(xiàn)男友一起去看了前任3.
    瑞兒姑娘閱讀 376評論 0 0
  • 表的基本概念 數(shù)據(jù)完整性:數(shù)據(jù)的準確性、可靠性 實體完整性約束:要求表中所有的行唯一 表當(dāng)中的每一行都是一個實體,...
    肉肉要次肉閱讀 557評論 0 0
  • 今天學(xué)習(xí)了兒童技能教養(yǎng)法,其中15個步驟,每一步都需要家長的理解和支持。孩子的改變需要家長智勇雙全,并引導(dǎo)...
    陽光1216閱讀 146評論 0 0

友情鏈接更多精彩內(nèi)容