跟着麦叔学flask,感谢b站麦叔
This commit is contained in:
12
templates/study/about.html
Executable file
12
templates/study/about.html
Executable file
@@ -0,0 +1,12 @@
|
||||
{# 引入base #}
|
||||
{% extends 'study/base.html' %}
|
||||
|
||||
{# 网站标签 #}
|
||||
{% block title %} 关于页面 {% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
大家好......
|
||||
没有了
|
||||
|
||||
{% endblock %}
|
||||
54
templates/study/base.html
Executable file
54
templates/study/base.html
Executable file
@@ -0,0 +1,54 @@
|
||||
{# base模板 #}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" lang="zh_CN">
|
||||
<title>{% block title %}{% endblock %}</title>
|
||||
<!--link rel="stylesheet" href="/static/css/style.css"-->
|
||||
{# 建立一个url,来源于static文件夹的,文件名字为css文件夹下的style.css #}
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
|
||||
</head>
|
||||
<body>
|
||||
<div style="width: 100%; background-color: rgb(122, 91, 246);">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="url">
|
||||
<a href="/study" class="url">home</a>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="url">
|
||||
<!--a href="/study/about" class="url">about</a-->
|
||||
<a href="{{ url_for('study.about')}}" class="url">about</a>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="url">
|
||||
<a href="/study/posts/new" class="url">新建文章</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
{% for message in get_flashed_messages() %}
|
||||
<div>{{ message }}</div>
|
||||
{% endfor %}
|
||||
|
||||
{% block content %} {% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<style>
|
||||
body {
|
||||
margin: 0 0 0 0;
|
||||
background-color: rgb(157, 209, 255);
|
||||
}
|
||||
|
||||
.url {
|
||||
height: 40px;
|
||||
margin: 10px 0 0 10px;
|
||||
color: rgb(0, 0, 0);
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
5
templates/study/delete.html
Executable file
5
templates/study/delete.html
Executable file
@@ -0,0 +1,5 @@
|
||||
<b>确定要删除 "{{ posts['title'] }}" 吗?</b>
|
||||
|
||||
<form action="{{ url_for('study.delete_posts_id', posts_id=posts['id']) }}" method="post">
|
||||
<input type="submit" value="删除文章" class="btn btn-danger htn-sm" onclick="return confirm('确定要删除吗')">
|
||||
</form>
|
||||
25
templates/study/edit.html
Executable file
25
templates/study/edit.html
Executable file
@@ -0,0 +1,25 @@
|
||||
{# 引入base #}
|
||||
{% extends 'study/base.html' %}
|
||||
|
||||
{# 网站标签 #}
|
||||
{% block title %} 编辑 "{{ posts['title'] }}" {% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<form method="post">
|
||||
<div class="form-group">
|
||||
<label for="title">标题</label>
|
||||
<input type="text" name="title" placeholder="标题" class="form-control" value="{{ request.form['title'] or posts['title'] }}">
|
||||
</inpit>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="content">内容</label>
|
||||
<textarea name="content" placeholder="文章内容" class="form-control">{{ request.form['content'] or posts['content'] }}</textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button type="submit" class="btn btn-primary">提交</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
20
templates/study/home.html
Executable file
20
templates/study/home.html
Executable file
@@ -0,0 +1,20 @@
|
||||
{# 引入base #}
|
||||
{% extends 'study/base.html' %}
|
||||
|
||||
{# 网站标签 #}
|
||||
{% block title %}study学习{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>学习如何搭建一个blog</h1>
|
||||
<h2>欢迎访问一个学习如何搭建一个blog的页面</h2>
|
||||
|
||||
{% for posts in posts %}
|
||||
<a href="/study/posts/{{ posts['id'] }}">
|
||||
<!--a href="{{ url_for('study.show_posts_id', posts_id=posts['id']) }}"-->
|
||||
<h2>{{ posts['title'] }}</h2>
|
||||
</a>
|
||||
<span>{{ posts['created_8'] }}</span>
|
||||
<hr>
|
||||
<br>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
25
templates/study/new.html
Executable file
25
templates/study/new.html
Executable file
@@ -0,0 +1,25 @@
|
||||
{# 引入base #}
|
||||
{% extends 'study/base.html' %}
|
||||
|
||||
{# 网站标签 #}
|
||||
{% block title %} 新建文章 {% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<form method="post">
|
||||
<div class="form-group">
|
||||
<label for="title">标题</label>
|
||||
<input type="text" name="title" placeholder="标题" class="form-control" value="{{ request.form['title'] }}">
|
||||
</inpit>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="content">内容</label>
|
||||
<textarea name="content" placeholder="文章内容" class="form-control">{{ request.form['content'] }}</textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button type="submit" class="btn btn-primary">提交</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
19
templates/study/posts.html
Executable file
19
templates/study/posts.html
Executable file
@@ -0,0 +1,19 @@
|
||||
{# 引入base #}
|
||||
{% extends 'study/base.html' %}
|
||||
|
||||
{# 网站标签 #}
|
||||
{% block title %} {{ posts['title'] }} {% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>{{ posts['title'] }}</h1>
|
||||
<span>{{ posts['created_8'] }}</span>
|
||||
<a href="./{{ posts['id'] }}/edit">
|
||||
<span>编辑</span>
|
||||
</a>
|
||||
<hr>
|
||||
|
||||
<p>{{ posts['content'] }}</p>
|
||||
|
||||
|
||||
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user