Ejemplo n.º 1
0
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())
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
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))')
Ejemplo n.º 6
0
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)
Ejemplo n.º 7
0
async def api(request):
    md = markdown2.markdown_path('app/templates/api.md')
    return jinja.render('api.html', request, md=md)
Ejemplo n.º 8
0
 async def get(self, request):
     if not auth.current_user(request):
         return jinja.render('login.html', request)
     return redirect('/')
Ejemplo n.º 9
0
    async def get(self, request):

        return jinja.render('index.html', request)
Ejemplo n.º 10
0
async def IOT(request):
    IOT_amount = db.IOT.objects.count()
    IOTS = db.IOT.objects
    return jinja.render('IOT.html', **locals())
Ejemplo n.º 11
0
async def index(request):
    user_amount = db.User.objects.count()
    users = db.User.objects
    return jinja.render('index.html', **locals())