Главное меню
Но список запросов пока представляет собой просто один запрос
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
<title>Заготовки на складе</title>
|
<title>Заготовки на складе</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<button><a href="{{ url_for('logout') }}">Выход</a></button>
|
||||||
{% if status %}
|
{% if status %}
|
||||||
<!-- Input -->
|
<!-- Input -->
|
||||||
<h1>Выберите материал</h1>
|
<h1>Выберите материал</h1>
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
from flask import Flask, render_template, session
|
from flask import Flask, render_template, session
|
||||||
from Queries.requests import requests_bp
|
from Queries.requests import requests_bp
|
||||||
from Auth.auth import auth_bp
|
from Auth.auth import auth_bp
|
||||||
|
from os import path
|
||||||
from checker import check_auth
|
from checker import check_auth
|
||||||
|
import json
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.secret_key = 'suplex'
|
app.secret_key = 'suplex'
|
||||||
@@ -10,13 +12,14 @@ app.register_blueprint(requests_bp, url_prefix='/requests')
|
|||||||
app.register_blueprint(auth_bp, url_prefix='/auth')
|
app.register_blueprint(auth_bp, url_prefix='/auth')
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
@check_auth
|
|
||||||
def index():
|
def index():
|
||||||
return render_template('index.html')
|
with open(path.join(path.dirname(__file__), 'datafiles/menu.json')) as f:
|
||||||
|
urls = json.load(f)
|
||||||
|
return render_template('main_menu.html', menu=urls, ses=session)
|
||||||
|
|
||||||
@app.route('/logout')
|
@app.route('/logout')
|
||||||
@check_auth
|
@check_auth
|
||||||
def logout():
|
def logout():
|
||||||
session.clear()
|
session.clear()
|
||||||
return 'OK'
|
return render_template('exit.html')
|
||||||
app.run(port=5001, debug=True)
|
app.run(port=5001, debug=True)
|
||||||
3
App/datafiles/menu.json
Normal file
3
App/datafiles/menu.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[
|
||||||
|
{"name": "Меню запросов", "url": "requests_bp.sklad_zapros"}
|
||||||
|
]
|
||||||
11
App/templates/exit.html
Normal file
11
App/templates/exit.html
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Успешно</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>До свидания!</h1>
|
||||||
|
<button><a href="{{ url_for('index') }}">На главную страницу</a></button>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -6,5 +6,10 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Hello World</h1>
|
<h1>Hello World</h1>
|
||||||
|
<nav class="menu">
|
||||||
|
{% for point in menu %}
|
||||||
|
<a class="middle" href="{{ point['url'] }}">{{ point['name'] }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
</nav>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
20
App/templates/main_menu.html
Normal file
20
App/templates/main_menu.html
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Главное меню</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Hello World</h1>
|
||||||
|
<nav class="menu">
|
||||||
|
{% if 'role' in ses %}
|
||||||
|
<a href="{{ url_for('logout') }}">Выход</a>
|
||||||
|
{% else %}
|
||||||
|
<a href="{{ url_for('auth_bp.auth') }}">Авторизация</a>
|
||||||
|
{% endif %}
|
||||||
|
{% for point in menu %}
|
||||||
|
<a href="{{ url_for(point['url']) }}">{{ point['name'] }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
</nav>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user