def home(request): try: print('settings.TEMPLATE_DIRS: ', settings.TEMPLATE_DIRS) path1 = os.path.join(settings.BASE_DIR, "sequencer/templates/sequencer") + '/home.html' print('path: ', path1) html = open(path1).read() from django.core.context_processors import csrf print("csrf(request): ", csrf(request)) response = HttpResponse(html) # response.set_cookie('stam_cookie', 'nechratz', expires=2) #, domain=settings.SESSION_COOKIE_DOMAIN, secure=settings.SESSION_COOKIE_SECURE or None) csrf_cookie = get_or_create_csrf_token(request) print("csrf_cookie: ", csrf_cookie) except Exception: print('exception: ', sys.exc_info) traceback.print_exc() return response
def jfu(context, template_name='jfu/upload_form.html', upload_handler_name='jfu_upload', *args, **kwargs): """ Displays a form for uploading files using jQuery File Upload. A user may use both a custom template or a custom upload-handling URL name by supplying values for template_name and upload_handler_name respectively. Any additionally supplied positional and keyword arguments are directly forwarded to the named custom upload-handling URL. """ context.update({ 'JQ_OPEN': '{%', 'JQ_CLOSE': '%}', 'upload_handler_url': reverse(upload_handler_name, args=args, kwargs=kwargs), }) # Use the request context variable, injected # by django.core.context_processors.request, # to generate the CSRF token. context.update(csrf(context.get('request'))) t = loader.get_template(template_name) return t.render(context.flatten())
def flixdra(request): c = {} c['CSRF_TOKEN'] = csrf(request) if request.method == 'POST': file = request.FILES['myfile'] url, awesome_content = parse_netflix(file.read()) c['graph_link'] = url c['awesome_content'] = awesome_content return render(request, "flixdra_results.html", c) else: return render(request, "flixdra.html", c)
def creator(request): c = {} c['csrftoken'] = csrf(request) return render(request, "create.html", c)
def see_all(request): c = {} c['CSRF_TOKEN'] = csrf(request) links = ShortLink.objects.all() c['links'] = links return render(request, "see_all.html", c)
def search_post(request): ctx ={} ctx.update(csrf(request)) if request.POST: ctx['rlt'] = request.POST['q'] return render(request, "post.html", ctx)