-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
36 lines (26 loc) · 1.01 KB
/
main.py
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
from flask import Flask, render_template, abort
from werkzeug import secure_filename
import sqlite3
import markdown
import os
app = Flask(__name__, static_url_path='')
base = "base.db"
conn = sqlite3.connect(base)
conn.row_factory = sqlite3.Row
@app.route("/")
def index():
return render_template("index.html", title="Главная")
@app.route("/shenka/")
def db():
result = conn.execute("select * from Measuring;")
return render_template("db.html", title="Измерители толщины", result=result)
@app.route("/blog/<int:year>/<int:month>/<int:day>/<title>")
def blog(year, month, day, title):
# написать нормальный код для загрузки файла
fname = 'blog/' + secure_filename('{:04d}-{:02d}-{:02d}-{}.md'.format(year, month, day, title))
if not os.path.exists(fname):
abort(404)
article = markdown.markdown(open(fname).read())
return render_template("article.html", article=article)
if __name__ == "__main__":
app.run(host="0.0.0.0")