-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.py
87 lines (71 loc) · 2.78 KB
/
start.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
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
86
87
from flask import Flask, render_template, request, url_for
import logs.log as log
import db.db as db
from db.db import blog_class, project_class
app = Flask(__name__)
app.config['SECRET_KEY'] = 'your secret key'
database = db.db("db/database.db");
@app.route("/")
@app.route("/home")
def index():
return render_template("index.html")
@app.route("/projects")
def projects():
projects = database.get_table(project_class())
return render_template("projects.html", projects=projects)
@app.route("/blog")
def blog():
blog = database.get_table(blog_class())
return render_template("blog.html", blog=blog)
@app.route("/socials")
def socials():
return render_template("socials.html")
@app.route("/modify/projects", methods=('GET', 'POST'))
def modify_project():
if request.method == 'POST':
action = request.form['action']
if action == "delete":
project = project_class()
project.id = request.form['id']
database.delete(project)
elif action == "create":
new_project = project_class()
new_project.name = request.form['name']
new_project.url = request.form['url']
new_project.color = request.form['color']
new_project.descr = request.form['descr']
database.set_new(new_project)
elif action == "modify":
modify_project = project_class()
modify_project.id = request.form['id']
modify_project.id_old = request.form['id_old']
modify_project.name = request.form['name']
modify_project.url = request.form['url']
modify_project.color = request.form['color']
modify_project.descr = request.form['descr']
database.update(modify_project)
projects = database.get_table(project_class())
return render_template("modify_project.html", projects=projects)
@app.route("/modify/blog", methods=('GET', 'POST'))
def modify_blog():
if request.method == 'POST':
action = request.form['action']
if action == "delete":
post = blog_class()
post.id = request.form['id']
database.delete(post)
elif action == "create":
new_post = blog_class()
new_post.title = request.form['title']
new_post.text = request.form['text']
database.set_new(new_post)
elif action == "modify":
modify_post = blog_class()
modify_post.id = request.form['id']
modify_post.title = request.form['title']
modify_post.text = request.form['text']
database.update(modify_post)
blog = database.get_table(blog_class())
return render_template("modify_blog_posts.html", blog=blog)
if __name__ == "__main__":
app.run(debug=True, host="0.0.0.0")