Files
MainSite/app/views.py
2024-02-29 01:04:07 +04:00

115 lines
3.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!env/bin/python3.10
# -*- coding: UTF-8 -*-
# Активация FLASK
from app import app # чтение из config.py, роуты
from flask import render_template # использование шаблонов
from flask import request # получение данных Cookie, GET и POST
import os # чтение куки и работа с файлами и папками
import sys # Подключаем свои библиотеки
sys.path.append("app/source")
import Pages # Страницы сайта
import API_Common as APIC
# Глобальные переменные
ProgName = app.config['PROGNAME']
version = app.config['VERSION']
appname = app.config['SHMNAME']
"""
LevelA = ""
Flag = False
FIO = ""
UserID = ""
tb_Hashpassword = ""
OldSession = ""
CurSessionID = ""
S = ['0', '1', '2', '3']
"""
###############################################################################
@app.errorhandler(413)
def request_entity_too_large(error):
return 'Превышен максимальный размер файла', 413
@app.errorhandler(404)
def page_not_found(e):
return """Здесь нет того, чего ты ищешь... <br><a href ="/"> Вернутся на главную</a> """, 404
###############################################################################
# Добавляем роуты
@app.route('/')
@app.route('/index')
@app.route('/about')
@app.route('/main')
def main():
Title = "Обо мне"
return render_template('about.htm',
UserHeader=UserHeader(Title, ProgName), version=version, Title=Title, ProgName=ProgName
)
########################################################################
# rustdesk
########################################################################
@app.route('/rustdesk', methods=['GET', 'POST'])
def route_rustdesk():
# Получаем куки и сессию
SessionID = request.cookies.get(appname + '_SessionID')
if request.method == 'POST':
return Pages.API(SessionID, "rustdesk") # Если POST запрос
else:
return Pages.Main(SessionID, "rustdesk") # Если GET запрос
###############################################################################
@app.route('/price')
def price():
Title = "Прайс"
return render_template('price.htm',
UserHeader=UserHeader(Title, ProgName), version=version, Title=Title, ProgName=ProgName
)
###############################################################################
@app.route('/portfolio')
def portfolio():
Title = "Отзывы"
return render_template('portfolio.htm',
UserHeader=UserHeader(Title, ProgName), version=version, Title=Title, ProgName=ProgName
)
###############################################################################
def UserHeader(Title, ProgName):
CurStr = ""
if (os.path.exists("app/templates/block_header.htm") == True):
file = open("app/templates/block_header.htm", "r")
CurStr = file.read()
file.close()
CurStr = CurStr.replace("{{ProgName}}", ProgName)
CurStr = CurStr.replace("{{Title}}", Title)
return CurStr
###############################################################################
@app.route('/favicon.ico')
def favicon1():
if (os.path.exists("app/static/image/favicon.ico") == True):
file = open("app/static/image/favicon.ico", "r")
CurStr = file.read()
file.close()
return CurStr