from datetime import datetime

from django.http import HttpResponse
from django.shortcuts import render


# Create your views here.
from django.views.decorators.csrf import csrf_exempt, csrf_protect

from App.models import User


def index(request):
    list1 = [1,2,3]
    title = 'hello'
    t1 = ('11','222')
    dict1 = {
        'hello':'world',
        'a':10
    }
    user = User.objects.get(pk=1)
    # return render(request,'two/index_1.html',context={
    #     'title':"jinja2的爸爸",
    #     'list1':[1,2,3,4]
    # })
    res = render(request,'two/index_1.html',context=locals())
    print(type(res))
    print(res.content)
    return res


def my_filter(request):
    name = "how are you"
    list1 = [1,2,4,5]
    a = 5
    b = 10
    d1 = datetime.now()
    label = "<h1>Hello<h1>"
    return render(request,'two/filter_2.html',context=locals())

#流程控制
def flowcontrol(request):
    return render(request,'two/flowcontrol.html',context={
        'a':10,
        'list1':[1,2,3,4,5]
    })

#局部禁止csrf验证
@csrf_exempt
def login(request):

    return render(request,'two/login.html')


def register(request):
    if request.method =="POST":
        print(request.POST)
        return HttpResponse("{'status':'ok'}")
    return render(request,'two/register.html')


def my_include(request):
    return render(request,'two/include1.html')


def bbs_index(request):
    return render(request,'bbs/base.html')


def list_category(request):
    return render(request,'bbs/list.html')