Flask基础学习4

19-【实战】问答平台项目结构搭建_剪_哔哩哔哩_bilibili

参考如上大佬的视频教程,本博客仅当学习笔记,侵权请联系删除


问答发布的web前端页面实现

register.html

html 复制代码
{% extends 'base.html' %}

{% block head %}
    <link rel="stylesheet" href="{{ url_for('static',filename='js/register.js') }}">
    <link rel="stylesheet" href="{{ url_for('static',filename='css/login_regist.css') }}">
{% endblock %}

{% block title %}注册{% endblock %}

{% block main %}
    <h3 class="page-title">注册</h3>
    <form method="post">
        <div class="form-container">
            <div class="form-group">
                <input type="text" name="email" placeholder="邮箱" class="form-control">
            </div>
            <div class="form-group">
            <label for="exampleInputEmail"></label>
                <div class="input-group" >
                    <input type="text" name="captcha" class="form-control">
                    <div class="input-group-append">
                        <button class="btn btn-outline-secondary" type="button" id="captcha-btn">获取验证码</button>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <input type="text" name="username" placeholder="用户名" class="form-control">
            </div>
            <div class="form-group">
                <input type="password" name="password" placeholder="密码" class="form-control">
            </div>
            <div class="form-group">
                <input type="password" name="password_confirm" placeholder="确认密码" class="form-control">
            </div>
            <div class="form-group">
                <button class="btn btn-primary btn-block">立即注册</button>
            </div>
        </div>
    </form>
{% endblock %}

login.html

html 复制代码
{% extends 'base.html' %}

{% block head %}
    <link rel="stylesheet" href="{{ url_for('static',filename='css/login_regist.css') }}">
{% endblock %}

{% block title %}登录{% endblock %}

{% block main %}
    <h3 class="page-title">登录</h3>
    <form method="post">
        <div class="form-container">
            <div class="form-group">
                <input type="text" name="email" placeholder="手机号码" class="form-control">
            </div>
            <div class="form-group">
                <input type="password" name="password" placeholder="密码" class="form-control">
            </div>
            <div class="form-group">
                <button class="btn btn-primary btn-block">立即登录</button>
            </div>
        </div>
    </form>
{% endblock %}

question.html

html 复制代码
{% extends 'base.html' %}

{% block head %}
    <link rel="stylesheet" href="{{ url_for('static',filename='css/question.css') }}">
{% endblock %}

{% block title %}发表问答{% endblock %}

{% block main %}
    <h3 class="page-title">发表问答</h3>
    <form method="post">
        <div class="form-container">
            <div class="form-group">
                <input name="title" type="text" placeholder="请输入标题" class="form-control">
            </div>
            <div class="form-group">
                <textarea name="context" placeholder="请输入内容" id="" class="form-control" rows="3"></textarea>
            </div>
            <div class="form-group" style="text-align: right;">
                <button class="btn btn-primary">提交</button>
            </div>
            </div>
    </form>
{% endblock %}

index.html

html 复制代码
{% extends 'base.html' %}
{% block head %}
    <link rel="stylesheet" href="{{ url_for('static',filename='css/index.css') }}">
{% endblock %}
{% block title %}
    首页
{% endblock %}

{% block main %}
    <ul class="question-ul">
        {% for question in questions %}
              <li>
                <div class="side-question">
                    <img class="side-question-avatar" src="{{ url_for('static',filename="images/zhiliao.png") }}" alt='照骗'>
                </div>
                <div class="question-main">
                    <p class="question-title"><a href="{{url_for('qa.qa_detail',qa_id=question.id)}}">{{ question.title }}</a></p>
                    <p class="question-content">{{ question.content }}</p>
                    <p class="question-detail">
                        <span class="question-author">{{ question.author.username }}</span>
                        <span class="question-time">{{ question.create_time }}</span>
                    </p>
                </div>
            </li>
        {% endfor %}
        </ul>
{% endblock %}

detail.html

html 复制代码
{% extends 'base.html' %}

{% block head %}
    <link rel="stylesheet" href="{{ url_for('static',filename='css/detail.css') }}">
{% endblock %}

{% block title %}详情{% endblock %}

{% block main %}
    <h3 class="page-title">{{ question.title }}</h3>
    <p class="question-info">
        <span>作者:{{ question.author.username }}</span>
        <span>时间:{{ question.create_time }}</span>
    </p>
    <hr>
    <p class="question-content">{{ question.content }}</p>
    <hr>
    <h4 class="comment-group-title">评论({{ question.answers|length }}):</h4>
    <form action="{{ url_for('qa.public_answer') }}" method="post">
        <input type="hidden" name="question_id" value="{{ question.id }}">
        <div class="form-container">
            <div class="form-group">
                <input type="text" placeholder="请填写评论" name="context" class="form-control">
            </div>
            <div class="form-group">
                <button class="btn btn-primary">评论</button>
            </div>
        </div>
    </form>
    <ul class="comment-group">
        {% for answer in question.answers %}
            <li>
                <div class="user-info">
                    <img class="avatar" src="{{ url_for('static',filename='images/zhiliao.png') }}" alt="">
                    <span class="username">{{ answer.author.username }}</span>
                    <span class="create-time">{{ answer.create_time }}</span>
                </div>
                <p class="comment-content">{{ answer.content }}</p>
            </li>
        {% endfor %}
    </ul>
{% endblock %}
相关推荐
小池先生5 分钟前
springboot启动不了 因一个spring-boot-starter-web底下的tomcat-embed-core依赖丢失
java·spring boot·后端
奶香臭豆腐41 分钟前
C++ —— 模板类具体化
开发语言·c++·学习
小蜗牛慢慢爬行1 小时前
如何在 Spring Boot 微服务中设置和管理多个数据库
java·数据库·spring boot·后端·微服务·架构·hibernate
波音彬要多做1 小时前
41 stack类与queue类
开发语言·数据结构·c++·学习·算法
wm10432 小时前
java web springboot
java·spring boot·后端
m0_748256782 小时前
WebGIS实战开源项目:智慧机场三维可视化(学习笔记)
笔记·学习·开源
南七澄江4 小时前
各种网站(学习资源及其他)
开发语言·网络·python·深度学习·学习·机器学习·ai
龙少95434 小时前
【深入理解@EnableCaching】
java·后端·spring
溟洵5 小时前
Linux下学【MySQL】表中插入和查询的进阶操作(配实操图和SQL语句通俗易懂)
linux·运维·数据库·后端·sql·mysql
SomeB1oody8 小时前
【Rust自学】6.1. 定义枚举
开发语言·后端·rust