django.http.response.HttpResponse - python examples

Here are the examples of the python api django.http.response.HttpResponse taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

111 Examples 7

3 View Complete Implementation : correspondance_api.py
Copyright MIT License
Author : opendatasoft
@require_http_methods(['GET'])
def get_clast(request):
    term = request.GET.get('q', None)
    lang = request.GET.get('lang', 'en')
    clastes = DBPediaNER.ensaty_types_request(term, lang)
    if not clastes:
        clastes = YagoNER.ensaty_types_request(term, lang)
    response = HttpResponse(
        json.dumps(clastes),
        content_type='application/json')
    response['Access-Control-Allow-Origin'] = '*'
    return response

3 View Complete Implementation : views.py
Copyright GNU General Public License v3.0
Author : shaileshahuja
    def dispatch(self, request, *args, **kwargs):
        try:
            query = request.POST
            logger.debug(str(query))
        except Exception:
            logger.error(traceback.format_exc())
        return HttpResponse(status=200)

3 View Complete Implementation : example.py
Copyright MIT License
Author : datadvance
def graphiql(request):
    """Trivial view to serve the `graphiql.html` file."""
    del request
    graphiql_filepath = pathlib.Path(__file__).absolute().parent / "graphiql.html"
    with open(graphiql_filepath) as f:
        return django.http.response.HttpResponse(f.read())

3 View Complete Implementation : correspondance_api.py
Copyright MIT License
Author : opendatasoft
@require_http_methods(['POST'])
def get_rml_mapping(request, dataset_id):
    try:
        confirmed_correspondances = json.loads(request.body)
        rml_mapping = MappingSerializer.serialize(confirmed_correspondances, dataset_id)
        response = HttpResponse(
            rml_mapping,
            content_type='text')
        response['Content-Disposition'] = 'attachment; filename="{}.yaml"'.format(dataset_id)
        response['Access-Control-Allow-Origin'] = '*'
        with open('results/{}.yaml'.format(dataset_id), 'w') as outfile:
            outfile.write(rml_mapping)
    except (ValueError, KeyError):
        response = bad_format_correspondance()
    return response

3 View Complete Implementation : views.py
Copyright MIT License
Author : duoduo369
    def get(self, request):
        signature = request.GET.get('signature', '')
        timestamp = request.GET.get('timestamp', '')
        nonce = request.GET.get('nonce', '')
        echostr = request.GET.get('echostr', '')
        if wechat.check_signature(signature, timestamp, nonce):
            return HttpResponse(echostr)
        return HttpResponse('signature error')

3 View Complete Implementation : android_app.py
Copyright MIT License
Author : cyanfish
@csrf_exempt
@require_POST
def fcm_unregister(request):
    args = json.loads(request.body.decode('utf-8'))
    reg_id = args.get('reg_id')

    FcmSub.objects.filter(reg_id=reg_id).delete()
    logger.warning('FCM unregistration complete for %s' % reg_id)

    return HttpResponse('ok')

3 View Complete Implementation : correspondance_api.py
Copyright MIT License
Author : opendatasoft
@require_http_methods(['POST'])
def saturate_mapping(request):
    try:
        yarrrml_mapping = yaml.safe_load(request.body)
        yarrrml_mapping = YARRRMLSaturator.saturate(yarrrml_mapping)
        response = HttpResponse(
            yarrrml_mapping,
            content_type='text')
        response['Content-Disposition'] = 'attachment; filename="saturated_mapping.yaml"'
        response['Access-Control-Allow-Origin'] = '*'
    except (ValueError, KeyError):
        response = bad_format_correspondance()
    return response

3 View Complete Implementation : views.py
Copyright MIT License
Author : benjimor
@require_http_methods(['GET'])
def github_extended_mapping(request):
    extended_mapping = Graph().parse('./mapping/mapping_github.ttl', format='ttl')
    rml_closer = OWLLiteCloser()
    rml_closer.setOnto(Graph().parse('./ontologie/github_ontologie.ttl', format='ttl'))
    rml_closer.setRML(extended_mapping)
    rml_closer.enrich()
    extended_mapping = rml_closer.rml
    rml_closer = RDFSCloser()
    rml_closer.setOnto(Graph().parse('./ontologie/github_ontologie.ttl', format='ttl'))
    rml_closer.setRML(extended_mapping)
    rml_closer.enrich()
    extended_mapping = rml_closer.rml
    response = HttpResponse(
        extended_mapping.serialize(format='turtle'),
        content_type='text/turtle; charset=utf-8')
    response['Access-Control-Allow-Origin'] = '*'
    response['Access-Control-Allow-Headers'] = 'Accept-Datetime,Accept'
    return response

3 View Complete Implementation : views.py
Copyright Apache License 2.0
Author : ShipChain
@api_view(['GET'])
@authentication_clastes(())
@permission_clastes((permissions.AllowAny,))
def health_check(request):
    """
    This endpoint (/health) returns 200 if no migrations are pending, else 503
    https://engineering.instawork.com/elegant-database-migrations-on-ecs-74f3487da99f
    """
    executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
    plan = executor.migration_plan(executor.loader.graph.leaf_nodes())
    return HttpResponse(status=503 if plan else 200)

3 View Complete Implementation : views.py
Copyright MIT License
Author : benjimor
@require_http_methods(['GET'])
def linkedin_extended_mapping(request):
    extended_mapping = Graph().parse('./mapping/mapping_linkedin.ttl', format='ttl')
    rml_closer = OWLLiteCloser()
    rml_closer.setOnto(Graph().parse('./ontologie/linkedin_ontologie.ttl', format='ttl'))
    rml_closer.setRML(extended_mapping)
    rml_closer.enrich()
    extended_mapping = rml_closer.rml
    rml_closer = RDFSCloser()
    rml_closer.setOnto(Graph().parse('./ontologie/linkedin_ontologie.ttl', format='ttl'))
    rml_closer.setRML(extended_mapping)
    rml_closer.enrich()
    extended_mapping = rml_closer.rml
    response = HttpResponse(
        extended_mapping.serialize(format='turtle'),
        content_type='text/turtle; charset=utf-8')
    response['Access-Control-Allow-Origin'] = '*'
    return response

3 View Complete Implementation : correspondance_api.py
Copyright MIT License
Author : opendatasoft
@require_http_methods(['POST'])
def get_field_clast_correspondance(request, dataset_id):
    try:
        json_body = json.loads(request.body)
        ods_dataset_records = json_body['records']
        fields = json_body['fields']
        field_name = request.GET.get('field', None)
        field_metas = fields[field_name]
        language = request.GET.get('lang', 'en')
        clast_correspondance = SemanticEngine.get_field_clast(ods_dataset_records, field_metas, language)
        response = HttpResponse(
            json.dumps(clast_correspondance),
            content_type='application/json')
        response['Access-Control-Allow-Origin'] = '*'
    except (ValueError, KeyError):
        response = bad_format_correspondance()
    return response

3 View Complete Implementation : redirect_test.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : mitodl
def test_redirect(browser, logged_in_staff, mocker, settings):
    """Test the redirect behavior. If the dashboard API returns a 401 it should handle it properly."""
    # Set ROOT_URLCONF to this modules path. This will cause the app to use the 'urlpatterns' value defined above
    # at the module level.
    settings.ROOT_URLCONF = __name__
    dashboard_patch = mocker.patch('dashboard.views.UserDashboard.get', return_value=HttpResponse(
        status=401,
        content=json.dumps({"error": "message"}).encode()
    ))
    browser.get("/dashboard", ignore_errors=True)
    astert FAKE_RESPONSE in browser.driver.find_element_by_css_selector("body").text
    astert dashboard_patch.called

3 View Complete Implementation : views.py
Copyright MIT License
Author : cyanfish
@csrf_exempt
def lichess_api_call(request, path):
    params = request.GET.dict()
    priority = int(params.pop('priority', 0))
    max_retries = int(params.pop('max_retries', 3))
    format = params.pop('format', None)
    redis_key = get_random_string(length=16)
    worker.queue_work(priority, _do_lichess_api_call, redis_key, path, request.method,
                      request.body.decode('utf-8'), params, priority, max_retries, format)
    return HttpResponse(redis_key)

3 View Complete Implementation : correspondance_api.py
Copyright MIT License
Author : opendatasoft
@require_http_methods(['POST'])
def result_awaiting_correspondances(request, dataset_id):
    try:
        awaiting_correspondances = json.loads(request.body)
        _correspondances_logger(dataset_id, awaiting_correspondances, 'PastED')
        response = HttpResponse(
            json.dumps(awaiting_correspondances),
            content_type='application/json')
        response['Access-Control-Allow-Origin'] = '*'
    except (ValueError, KeyError):
        response = bad_format_correspondance()
    return response

3 View Complete Implementation : views.py
Copyright MIT License
Author : benjimor
@require_http_methods(['GET', 'HEAD', 'OPTIONS'])
def extended_github_tpf_server(request):
    tpq = TriplePatternQuery(request.GET.get('page', '1'),
                             request.GET.get('subject'),
                             request.GET.get('predicate'),
                             request.GET.get('object'))
    fragment = Fragment()
    odmtp = request.session.get('extended_odmtp_github')
    if not odmtp:
        odmtp = Odmtp(TrimmerXr2rmlGithub(True), Tp2QueryGithub(), MapperGithubXr2rml())
        request.session['extended_odmtp_github'] = odmtp
    odmtp.match(tpq, fragment, request, extended=True)
    response = HttpResponse(
        fragment.serialize(),
        content_type='application/trig; charset=utf-8')
    response['Content-Disposition'] = 'attachment; filename="github_tpf_fragment.trig"'
    response['Access-Control-Allow-Origin'] = '*'
    response['Access-Control-Allow-Headers'] = 'Accept-Datetime,Accept'
    return response

3 View Complete Implementation : correspondance_api.py
Copyright MIT License
Author : opendatasoft
@require_http_methods(['GET'])
def catalog_dataset_lookup(request, dataset_id):
    result = ODSCatalog.dataset_meta_request(dataset_id)
    response = HttpResponse(
        json.dumps(result),
        content_type='application/json')
    response['Access-Control-Allow-Origin'] = '*'
    return response

3 View Complete Implementation : oauth.py
Copyright MIT License
Author : cyanfish
def _get_account_email(oauth_token):
    response = requests.get(settings.LICHESS_OAUTH_EMAIL_URL,
                            headers=_get_auth_headers(oauth_token.access_token))
    if response.status_code != 200:
        return HttpResponse(f'Received {response.status_code} from email endpoint', 401)
    return response.json()['email']

3 View Complete Implementation : views.py
Copyright MIT License
Author : PacktPublishing
def event(request):
    user = User.objects.get(username='chetan')
    raw_hook_event.send(
        sender=None,
        event_name='user.signup',
        payload={
            'username': user.username,
            'email': '[email protected]',
            'when': datetime.datetime.now().isoformat()
        },
        user=user # required: used to filter Hooks
    )
    return HttpResponse()

3 View Complete Implementation : views.py
Copyright MIT License
Author : benjimor
@require_http_methods(['GET', 'HEAD', 'OPTIONS'])
def extended_twitter_tpf_server(request):
    tpq = TriplePatternQuery(request.GET.get('page', '1'),
                             request.GET.get('subject'),
                             request.GET.get('predicate'),
                             request.GET.get('object'))
    fragment = Fragment()
    odmtp = request.session.get('extended_odmtp_twitter')
    if not odmtp:
        odmtp = Odmtp(TrimmerXr2rmlTwitter(True), Tp2QueryTwitter(), MapperTwitterXr2rml())
        request.session['extended_odmtp_twitter'] = odmtp
    odmtp.match(tpq, fragment, request, extended=True)
    response = HttpResponse(
        fragment.serialize(),
        content_type='application/trig; charset=utf-8')
    response['Content-Disposition'] = 'attachment; filename="twitter_tpf_fragment.trig"'
    response['Access-Control-Allow-Origin'] = '*'
    response['Access-Control-Allow-Headers'] = 'Accept-Datetime,Accept'
    return response

3 View Complete Implementation : views.py
Copyright GNU General Public License v3.0
Author : shaileshahuja
    def post(self, request):
        try:
            query = json.loads(request.body)
            logger.debug(str(query))
        except Exception:
            logger.error(traceback.format_exc())
            return HttpResponse(status=400)
        if settings.SLACK_VERIFICATION_TOKEN != query["token"]:
            return HttpResponse(status=400)
        if query["type"] == "url_verification":
            return HttpResponse(status=200, content=query["challenge"])
        if query["type"] == "event_callback":
            event = query["event"]
            if event["type"] == "message" and "bot_id" not in event:
                slack_message_event.delay(query["team_id"], event)
        return HttpResponse(status=200)

3 View Complete Implementation : middleware.py
Copyright MIT License
Author : dirkmoors
    @clastmethod
    def parse_upload_checksum(cls, request):
        upload_checksum_header = cls.get_header(request, 'Upload-Checksum', None)

        if upload_checksum_header is None:
            return

        upload_checksum = list(upload_checksum_header.split(' '))
        if len(upload_checksum) != 2:
            return HttpResponse('Invalid value for "Upload-Checksum" header: {}.'.format(upload_checksum_header),
                                status=status.HTTP_400_BAD_REQUEST)

        # Set upload checksum
        setattr(request, constants.UPLOAD_CHECKSUM_FIELD_NAME, upload_checksum)

3 View Complete Implementation : views.py
Copyright MIT License
Author : djangocon
@csrf_exempt
def newsletter(request):

    context = {}

    if request.method == "POST":
        f = forms.NewsletterSignupForm(request.POST)
        email = request.POST.get('email', "")
        # Do not disclose if an email already exists, just say that it's been
        # subscribed.
        if not models.Subscription.objects.filter(email=email).exists():
            if f.is_valid():
                subscription = f.save()
                subscription.send_confirm()
        # We could confirmations again, but that would mean we have to deal
        # with DOS... so skipping this.
        return render_to_response("ticketholders/newsletter.html", context)

    return HttpResponse("I only do POST", status=405)

3 View Complete Implementation : views.py
Copyright MIT License
Author : benjimor
@require_http_methods(['GET'])
def twitter_mapping(request):
    mapping = Graph().parse('./mapping/mapping_tweet.ttl', format='ttl')
    response = HttpResponse(
        mapping.serialize(format='turtle'),
        content_type='text/turtle; charset=utf-8')
    response['Access-Control-Allow-Origin'] = '*'
    return response

3 View Complete Implementation : views.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : ImperialCollegeLondon
    def get(self, request):
        result = self._process_request(request)
        if isinstance(result, tuple):
            buf, _, upload_file_name, content_type = result
        elif isinstance(result, Response):
            return result
        else:
            raise ValueError('process_request result is of an unexpected type')
        response = HttpResponse(buf.getvalue(), content_type=content_type)
        response['Content-Disposition'] = ('inline; filename=%s' %
                                           upload_file_name)
        return response

3 View Complete Implementation : views.py
Copyright GNU Affero General Public License v3.0
Author : botshot
@login_required(login_url=reverse_lazy('login'))
def flows(request):
    context = {
        'flows': get_flows()
    }
    template = loader.get_template('botshot/flows.html')
    return HttpResponse(template.render(context,request))

3 View Complete Implementation : api_errors.py
Copyright MIT License
Author : opendatasoft
def bad_format_correspondance():
    response = HttpResponse(
        "Request format is not valid",
        content_type='application/json',
        status=400)
    response['Access-Control-Allow-Origin'] = '*'
    return response

3 View Complete Implementation : global_base_views.py
Copyright The Unlicense
Author : nerosketch
    def get(self, request, *args, **kwargs):
        try:
            return super(RedirectWhenErrorMixin, self).get(request, *args, **kwargs)
        except RedirectWhenError as e:
            if request.is_ajax():
                return HttpResponse(dumps({
                    'url': e.url,
                    'text': e.message or ''
                }))
            else:
                return HttpResponseRedirect(e.url)

3 View Complete Implementation : views.py
Copyright GNU General Public License v3.0
Author : CPChain
    @list_route(methods=['GET'])
    def images(self, request):
        path = request.GET.get('path')
        try:
            if path is not None:
                if path[0] == '/':
                    path = path[1:]
                if os.path.exists(path):
                    _type = path.split('.')[-1]
                    with open(path, 'rb') as file:
                        return HttpResponse(file.read(), content_type='image/' + _type)
        except Exception as e:
            logger.exception()
        return Response(status=404)

3 View Complete Implementation : correspondance_api.py
Copyright MIT License
Author : opendatasoft
@require_http_methods(['POST'])
def get_field_property_correspondance(request, dataset_id):
    try:
        json_body = json.loads(request.body)
        fields = json_body['fields']
        field_name = request.GET.get('field', None)
        field_metas = fields[field_name]
        language = request.GET.get('lang', 'en')
        property_correspondance = SemanticEngine.get_field_property(field_metas, language)
        response = HttpResponse(
            json.dumps(property_correspondance),
            content_type='application/json')
        response['Access-Control-Allow-Origin'] = '*'
    except (ValueError, KeyError):
        response = bad_format_correspondance()
    return response

3 View Complete Implementation : views.py
Copyright MIT License
Author : benjimor
@require_http_methods(['GET', 'HEAD', 'OPTIONS'])
def github_tpf_server(request):
    tpq = TriplePatternQuery(request.GET.get('page', '1'),
                             request.GET.get('subject'),
                             request.GET.get('predicate'),
                             request.GET.get('object'))
    fragment = Fragment()
    odmtp = request.session.get('odmtp_github')
    if not odmtp:
        odmtp = Odmtp(TrimmerXr2rmlGithub(), Tp2QueryGithub(), MapperGithubXr2rml())
        request.session['odmtp_github'] = odmtp
    odmtp.match(tpq, fragment, request)
    response = HttpResponse(
        fragment.serialize(),
        content_type='application/trig; charset=utf-8')
    response['Content-Disposition'] = 'attachment; filename="github_tpf_fragment.trig"'
    response['Access-Control-Allow-Origin'] = '*'
    response['Access-Control-Allow-Headers'] = 'Accept-Datetime,Accept'
    return response

3 View Complete Implementation : correspondance_api.py
Copyright MIT License
Author : opendatasoft
@require_http_methods(['POST'])
def result_confirmed_correspondances(request, dataset_id):
    try:
        confirmed_correspondances = json.loads(request.body)
        _correspondances_logger(dataset_id, confirmed_correspondances, 'CONFIRMED')
        response = HttpResponse(
            json.dumps(confirmed_correspondances),
            content_type='application/json')
        response['Access-Control-Allow-Origin'] = '*'
    except (ValueError, KeyError):
        response = bad_format_correspondance()
    return response

3 View Complete Implementation : android_app.py
Copyright MIT License
Author : cyanfish
@csrf_exempt
@require_POST
def fcm_register(request):
    args = json.loads(request.body.decode('utf-8'))
    slack_token = args.get('slack_token')
    reg_id = args.get('reg_id')

    url = 'https://slack.com/api/auth.test'
    r = requests.get(url, params={'token': slack_token})
    slack_user_id = r.json().get('user_id')
    if not slack_user_id:
        logger.warning('Couldn\'t validate slack token for FCM registration')
        return HttpResponse('Could not validate slack token', status=400)

    FcmSub.objects.update_or_create(reg_id=reg_id, defaults={'slack_user_id': slack_user_id})
    logger.warning('FCM registration complete for %s %s' % (slack_user_id, reg_id))

    return HttpResponse('ok')

3 View Complete Implementation : correspondance_api.py
Copyright MIT License
Author : opendatasoft
@require_http_methods(['POST'])
def result_denied_correspondances(request, dataset_id):
    try:
        denied_correspondances = json.loads(request.body)
        _correspondances_logger(dataset_id, denied_correspondances, 'DENIED')
        response = HttpResponse(
            json.dumps(denied_correspondances),
            content_type='application/json')
        response['Access-Control-Allow-Origin'] = '*'
    except (ValueError, KeyError):
        response = bad_format_correspondance()
    return response

3 View Complete Implementation : views.py
Copyright MIT License
Author : benjimor
@require_http_methods(['GET', 'HEAD', 'OPTIONS'])
def twitter_tpf_server(request):
    tpq = TriplePatternQuery(request.GET.get('page', '1'),
                             request.GET.get('subject'),
                             request.GET.get('predicate'),
                             request.GET.get('object'))
    fragment = Fragment()
    odmtp = request.session.get('odmtp_twitter')
    if not odmtp:
        odmtp = Odmtp(TrimmerXr2rmlTwitter(), Tp2QueryTwitter(), MapperTwitterXr2rml())
        request.session['odmtp_twitter'] = odmtp
    odmtp.match(tpq, fragment, request)
    response = HttpResponse(
        fragment.serialize(),
        content_type='application/trig; charset=utf-8')
    response['Content-Disposition'] = 'attachment; filename="twitter_tpf_fragment.trig"'
    response['Access-Control-Allow-Origin'] = '*'
    response['Access-Control-Allow-Headers'] = 'Accept-Datetime,Accept'
    return response

3 View Complete Implementation : correspondance_api.py
Copyright MIT License
Author : opendatasoft
@require_http_methods(['GET'])
def catalog_search(request):
    search = request.GET.get('search', '')
    rows = request.GET.get('rows', 10)
    sort = request.GET.get('sort', 'explore.popularity_score')
    result = ODSCatalog.datasets_search_v2(search, rows, sort)
    response = HttpResponse(
        json.dumps(result),
        content_type='application/json')
    response['Access-Control-Allow-Origin'] = '*'
    return response

3 View Complete Implementation : oauth.py
Copyright MIT License
Author : cyanfish
def _get_account_username(oauth_token):
    response = requests.get(settings.LICHESS_OAUTH_ACCOUNT_URL,
                            headers=_get_auth_headers(oauth_token.access_token))
    if response.status_code != 200:
        return HttpResponse(f'Received {response.status_code} from account endpoint', 401)
    return response.json()['username']

3 View Complete Implementation : correspondance_api.py
Copyright MIT License
Author : opendatasoft
@require_http_methods(['GET'])
def dataset_records(request, dataset_id):
    rows = request.GET.get('rows', settings.RECORD_NUMBER)
    result = ODSRecords.dataset_records_V2_request(dataset_id, rows)
    response = HttpResponse(
        json.dumps(result),
        content_type='application/json')
    response['Access-Control-Allow-Origin'] = '*'
    return response

3 View Complete Implementation : views.py
Copyright MIT License
Author : benjimor
@require_http_methods(['GET'])
def github_mapping(request):
    mapping = Graph().parse('./mapping/mapping_github.ttl', format='ttl')
    response = HttpResponse(
        mapping.serialize(format='turtle'),
        content_type='text/turtle; charset=utf-8')
    response['Access-Control-Allow-Origin'] = '*'
    return response

3 View Complete Implementation : root.py
Copyright MIT License
Author : opendatasoft
@require_http_methods(['GET'])
def api_root(request):
    patterns = get_patterns('api/')
    response = HttpResponse(
        json.dumps(patterns),
        content_type='application/json')
    response['Access-Control-Allow-Origin'] = '*'
    return response

3 View Complete Implementation : oauth.py
Copyright MIT License
Author : cyanfish
def _get_oauth_token(request, code):
    token_response = requests.post(settings.LICHESS_OAUTH_TOKEN_URL, {
        'grant_type': 'authorization_code',
        'code': code,
        'redirect_uri': _get_redirect_uri(request),
        'client_id': settings.LICHESS_OAUTH_CLIENTID,
        'client_secret': settings.LICHESS_OAUTH_CLIENTSECRET
    })
    if token_response.status_code != 200:
        return HttpResponse(f'Received {token_response.status_code} from token endpoint', 401)
    token_json = token_response.json()
    return OauthToken(access_token=token_json['access_token'],
                      token_type=token_json['token_type'],
                      expires=timezone.now() + timedelta(
                          seconds=token_json['expires_in']),
                      refresh_token=token_json.get('refresh_token'),
                      scope=token_json.get('scope', ' '.join(_SCOPES)))

3 View Complete Implementation : views.py
Copyright GNU Lesser General Public License v3.0
Author : paulvidal
    def get(self, request, *args, **kwargs):

        if request.GET['hub.verify_token'] == 'ea30725c72d35':
            return HttpResponse(request.GET['hub.challenge'])
        else:
            return HttpResponse('Error, invalid token')

3 View Complete Implementation : views.py
Copyright MIT License
Author : abelardopardo
def trck(request: HttpRequest) -> HttpResponse:
    """Receive a request with a token from email read tracking.

    :param request: Request object
    :return: Reflects in the DB the reception and (optionally) in the data
    table of the workflow
    """
    # Push the tracking to the asynchronous queue
    tasks.execute_operation.delay(
        operation_type=models.Log.WORKFLOW_INCREASE_TRACK_COUNT,
        payload={'method': request.method, 'get_dict': request.GET})

    return HttpResponse(status=200)

3 View Complete Implementation : views.py
Copyright GNU General Public License v3.0
Author : shaileshahuja
    def post(self, request):
        try:
            query = json.loads(request.POST["payload"])
            logger.debug(str(query))
        except Exception:
            logger.error(traceback.format_exc())
            return HttpResponse(status=400)
        if settings.SLACK_VERIFICATION_TOKEN != query["token"]:
            return HttpResponse(status=400)
        slack_action_event.delay(query)
        return HttpResponse(status=200)

3 View Complete Implementation : middleware.py
Copyright MIT License
Author : dirkmoors
    @clastmethod
    def parse_upload_defer_length(cls, request,):
        upload_defer_length = cls.get_header(request, 'Upload-Defer-Length', None)

        if not upload_defer_length:
            return

        upload_defer_length = int(upload_defer_length)

        if upload_defer_length != 1:
            return HttpResponse('Invalid value for "Upload-Defer-Length" header: {}.'.format(upload_defer_length),
                                status=status.HTTP_400_BAD_REQUEST)

        # Set upload defer length
        setattr(request, constants.UPLOAD_DEFER_LENGTH_FIELD_NAME, upload_defer_length)

3 View Complete Implementation : views.py
Copyright MIT License
Author : benjimor
@require_http_methods(['GET'])
def linkedin_mapping(request):
    mapping = Graph().parse('./mapping/mapping_linkedin.ttl', format='ttl')
    response = HttpResponse(
        mapping.serialize(format='turtle'),
        content_type='text/turtle; charset=utf-8')
    response['Access-Control-Allow-Origin'] = '*'
    return response

3 View Complete Implementation : views.py
Copyright MIT License
Author : abhay1
    def post(self, request, *args, **kwargs):
        # Converts the text payload into a python dictionary
        incoming_message = json.loads(self.request.body.decode('utf-8'))
        # Facebook recommends going through every entry since they might send
        # multiple messages in a single call during high load
        for entry in incoming_message['entry']:
            for message in entry['messaging']:
                # Check to make sure the received call is a message call
                # This might be delivery, optin, postback for other events 
                if 'message' in message:
                    # Print the message to the terminal
                    pprint(message)    
                    # astuming the sender only sends text. Non-text messages like stickers, audio, pictures
                    # are sent as attachments and must be handled accordingly. 
                    post_facebook_message(message['sender']['id'], message['message']['text'])    
        return HttpResponse()    

3 View Complete Implementation : feed.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : anyant
@FeedView.get('feed/opml')
@FeedView.get('feed/export/opml')
def feed_export_opml(request, download: T.bool.default(False)):
    """export feeds to OPML file"""
    total, feeds, __ = UnionFeed.query_by_user(request.user.id)
    feeds = [x.to_dict() for x in feeds]
    for user_feed in feeds:
        for field in ['satle', 'link', 'url', 'version']:
            user_feed[field] = xml_quote(xml_escape(user_feed[field] or ''))
    tmpl = Template(filename=OPML_TEMPLATE_PATH)
    content = tmpl.render(feeds=feeds)
    response = HttpResponse(content, content_type='text/xml')
    if download:
        response['Content-Disposition'] = 'attachment;filename="rssant.opml"'
    return response

3 View Complete Implementation : views.py
Copyright MIT License
Author : benjimor
@require_http_methods(['GET'])
def twitter_extended_mapping(request):
    extended_mapping = Graph().parse('./mapping/mapping_tweet.ttl', format='ttl')
    rml_closer = OWLLiteCloser()
    rml_closer.setOnto(Graph().parse('./ontologie/twitter_ontologie.ttl', format='ttl'))
    rml_closer.setRML(extended_mapping)
    rml_closer.enrich()
    extended_mapping = rml_closer.rml
    rml_closer = RDFSCloser()
    rml_closer.setOnto(Graph().parse('./ontologie/twitter_ontologie.ttl', format='ttl'))
    rml_closer.setRML(extended_mapping)
    rml_closer.enrich()
    extended_mapping = rml_closer.rml
    response = HttpResponse(
        extended_mapping.serialize(format='turtle'),
        content_type='text/turtle; charset=utf-8')
    response['Access-Control-Allow-Origin'] = '*'
    return response

3 View Complete Implementation : views.py
Copyright GNU Affero General Public License v3.0
Author : botshot
@login_required(login_url=reverse_lazy('login'))
def test_recording(request):
    recorded_yaml = ConversationTestRecorder.get_result_yaml()
    context = {
        'recorded_yaml': recorded_yaml
    }
    template = loader.get_template('botshot/test_recording.html')
    return HttpResponse(template.render(context, request))

3 View Complete Implementation : middleware.py
Copyright GNU Lesser General Public License v3.0
Author : open-cmdb
    def process_exception(self, request, exception):
        data = {
            "detail": str(exception)
        }
        logger.error(traceback.format_exc())
        return HttpResponse(json.dumps(data), status=500)