async def login(request): if request.method == 'POST': username = request.form.get('username') password = request.form.get('password') if username == user.name and password == user.password: auth.login_user(request, user) return response.redirect('/') return jinja.render('login.html', **locals())
async def daily(request): data_db = sqlite3.connect('data.db') data_cursor = data_db.cursor() data_cursor.execute('''SELECT items FROM dailyrotations''') items = data_cursor.fetchone() if items is not None: items = eval(items[0]) else: items = {'name': 'Нет данных. Проверьте позднее.', 'items': []} data_db.close() return jinja.render('daily.html', request, global_items=items)
async def get(self, request): """ 接收消息页面 :param request: :return: """ connect_info = generate_token(app.config.CENTRIFUGO_SECRET, user_id) connect_info.update({'url': app.config.CENTRIFUGO_CLIENT_URL}) return jinja.render('receiver.html', request, connect_info=connect_info, channel=channel)
async def weekly(request): data_db = sqlite3.connect('data.db') data_cursor = data_db.cursor() data_cursor.execute('''SELECT items FROM weeklyrotations''') items = data_cursor.fetchone() if items is not None: items = eval(items[0]) else: items = [{ 'name': 'Нет данных, или они пока что не предоставляются. Проверьте позднее.', 'items': [] }] data_db.close() return jinja.render('weekly.html', request, global_items=items)
async def ev_weekly(request): data_db = sqlite3.connect('data.db') data_cursor = data_db.cursor() data_cursor.execute('''SELECT items FROM evweekly''') items = data_cursor.fetchone() if items is not None: items = eval(items[0]) else: items = [{ 'name': 'Нет данных, или они пока что не предоставляются. Проверьте позднее.', 'items': [] }] data_db.close() return jinja.render( 'evweekly.html', request, global_items=items, item_style='max-width: 400px', global_style= 'grid-template-columns: repeat(auto-fit, minmax(250px,1fr))')
async def dyn_daily(request): data_db = mariadb.connect(host=api_data['db_host'], user=api_data['cache_login'], password=api_data['pass'], port=api_data['db_port'], database=api_data['data_db']) db_cursor = data_db.cursor() items = [] db_cursor.execute( '''SELECT json, name, size, template, annotations FROM ru WHERE type='daily' ORDER BY place ASC''' ) data = db_cursor.fetchall() for item in data: items.append({ 'name': item[1], 'size': item[2], 'items': json.loads(item[0])['data'], 'template': item[3], 'annotations': eval(item[4]) }) data_db.close() return jinja.render('daily.html', request, global_items=items)
async def api(request): md = markdown2.markdown_path('app/templates/api.md') return jinja.render('api.html', request, md=md)
async def get(self, request): if not auth.current_user(request): return jinja.render('login.html', request) return redirect('/')
async def get(self, request): return jinja.render('index.html', request)
async def IOT(request): IOT_amount = db.IOT.objects.count() IOTS = db.IOT.objects return jinja.render('IOT.html', **locals())
async def index(request): user_amount = db.User.objects.count() users = db.User.objects return jinja.render('index.html', **locals())