forked from yancai/blog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblog.py
More file actions
85 lines (59 loc) · 1.52 KB
/
blog.py
File metadata and controls
85 lines (59 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/python
# -*- coding:utf-8 -*-
"""Documentation"""
from flask import Flask, render_template
from api.views import api
app = Flask(__name__)
@app.errorhandler(404)
def page_not_found(error):
return render_template("404.html"), 404
@app.errorhandler(500)
def internal_error(error):
return render_template("500.html"), 500
@app.route("/favicon.ico")
def get_favicon():
"""favicon.ico
"""
return app.send_static_file("favicon.ico")
@app.route("/")
def page_index():
"""页面-首页
"""
return render_template("index.html")
@app.route("/about/")
def page_about():
"""页面-关于
"""
return app.send_static_file("out/About.html")
@app.route("/article/<aid>/")
def page_article(aid):
"""页面-获取指定id的文章
"""
return app.send_static_file("out/{}.html".format(aid))
@app.route("/articles/")
def page_articles():
"""页面-全部文章列表
"""
return render_template("articles.html")
@app.route("/tags/")
def page_tags():
"""页面-全部标签
"""
return render_template("tags.html")
@app.route("/tag/<tag>/")
def page_article_by_tag(tag):
"""页面-指定标签的文章列表
"""
return render_template("articles_by_tag.html", tag=tag)
@app.route("/upload/")
def page_upload():
return render_template("upload.html")
# 注册api接口的blueprint
app.register_blueprint(api, url_prefix="/api")
if __name__ == "__main__":
app.run(
host="0.0.0.0",
port=5000,
debug=False,
)
pass