http://localhost:8000/polls/?url=https://yahoo.com
raise_for_statusってのは、 Responseオブジェクトのステータスコードが200番台以外だったら、例外を起こすってことです。
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.shortcuts import render from django.http import HttpResponse # Create your views here. import requests def index(request): url = request.GET.get('url') if url: res = requests.get(url) #この分岐は本当のサイトに繋げないので、<b>モックでMT</b>を実施する。 res.raise_for_status() return HttpResponse(res.content, content_type=res.headers.get('content-type', 'text/plain')) else: return HttpResponse('Hello Nikotto World')
node.jsだと思っていたけれど、知見を集約するにはこういう考えもあるね