build0011
This commit is contained in:
@@ -47,3 +47,15 @@ def load_data(text):
|
|||||||
res.append(datas)
|
res.append(datas)
|
||||||
code = 1
|
code = 1
|
||||||
return {"code":code, "results":res}
|
return {"code":code, "results":res}
|
||||||
|
|
||||||
|
def remove_data(uid):
|
||||||
|
try:
|
||||||
|
data = db.load("pages")
|
||||||
|
except:
|
||||||
|
data = {"0":{"url":"0", "title":"0", "text":""}}
|
||||||
|
if uid not in data:
|
||||||
|
return {"code":0}
|
||||||
|
datas = data[uid]
|
||||||
|
del data[uid]
|
||||||
|
db.save("pages", data)
|
||||||
|
return {"code":1, "uid":uid, datas}
|
||||||
@@ -27,6 +27,23 @@ def add_page_r():
|
|||||||
text = "<p>" + data["uid"] + " - <a href='" + data["data"]["url"] + "'>"+ data["data"]["title"] + "</a>" + "</p>"
|
text = "<p>" + data["uid"] + " - <a href='" + data["data"]["url"] + "'>"+ data["data"]["title"] + "</a>" + "</p>"
|
||||||
return html_page.format(title=title, text=text)
|
return html_page.format(title=title, text=text)
|
||||||
|
|
||||||
|
@app.route('/remove_page')
|
||||||
|
def remove_page():
|
||||||
|
return render_template('remove_page.html')
|
||||||
|
|
||||||
|
@app.route('/remove_page', methods=('GET', 'POST'))
|
||||||
|
def remove_page_r():
|
||||||
|
uid = request.form['uid']
|
||||||
|
data = main.remove_data(uid)
|
||||||
|
html_page = open("templates/blanks.html", "r").read()
|
||||||
|
if data["code"] == 0:
|
||||||
|
title = "Страница по UID отсутсвует в каталоге"
|
||||||
|
text = "<p>" + uid + "</p>"
|
||||||
|
else:
|
||||||
|
title = "Страница удалена из каталога"
|
||||||
|
text = "<p>" + data["uid"] + " - <a href='" + data["data"]["url"] + "'>"+ data["data"]["title"] + "</a>" + "</p>"
|
||||||
|
return html_page.format(title=title, text=text)
|
||||||
|
|
||||||
@app.route('/statics/<string:file_name>')
|
@app.route('/statics/<string:file_name>')
|
||||||
def statics(file_name):
|
def statics(file_name):
|
||||||
return send_from_directory(os.getcwd()+"/static", file_name)
|
return send_from_directory(os.getcwd()+"/static", file_name)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="contentdiv">
|
<div class="contentdiv">
|
||||||
<div id="lista">
|
<div id="lista">
|
||||||
<a href="/">Главная страница</a>
|
<a href="/">Главная страница</a> | <a href="/remove_page">Удалить страницу</a>
|
||||||
<form action="/add_page" method="post">
|
<form action="/add_page" method="post">
|
||||||
<input type="text" name="url" placeholder="URL" class="form-control"></input>
|
<input type="text" name="url" placeholder="URL" class="form-control"></input>
|
||||||
<button type="submit" class="btn btn-primary">ADD</button>
|
<button type="submit" class="btn btn-primary">ADD</button>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="contentdiv">
|
<div class="contentdiv">
|
||||||
<div id="lista">
|
<div id="lista">
|
||||||
<a href="/add_page">Добавить страницу</a>
|
<a href="/add_page">Добавить страницу</a> | <a href="/remove_page">Удалить страницу</a>
|
||||||
<form action="/search" method="post">
|
<form action="/search" method="post">
|
||||||
<input type="text" name="text" placeholder="Search query" class="form-control"></input>
|
<input type="text" name="text" placeholder="Search query" class="form-control"></input>
|
||||||
<button type="submit" class="btn btn-primary">Search</button>
|
<button type="submit" class="btn btn-primary">Search</button>
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Nyako Page</title>
|
||||||
|
<link rel="stylesheet" href="/statics/style.css">
|
||||||
|
<meta name="viewport" content="width=device-width">
|
||||||
|
<!--
|
||||||
|
<meta name="viewport" content="height=device-height">
|
||||||
|
<meta name="viewport" content="user-scalable=yes">
|
||||||
|
-->
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="maindiv">
|
||||||
|
<img src="/statics/head2.png" alt="Head Image">
|
||||||
|
<div id="bodydiv">
|
||||||
|
<div class="titlediv">
|
||||||
|
<h1><code>Удалить страницу</code></h1>
|
||||||
|
</div>
|
||||||
|
<div class="contentdiv">
|
||||||
|
<div id="lista">
|
||||||
|
<a href="/">Главная страница</a> | <a href="/add_page">Добавить страницу</a>
|
||||||
|
<form action="/remove_page" method="post">
|
||||||
|
<input type="text" name="url" placeholder="UID" class="form-control"></input>
|
||||||
|
<button type="submit" class="btn btn-primary">REMOVE</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user