コード例 #1
0
ファイル: views.py プロジェクト: foulglory/CloudEngine
    def post(self, request):
        app = request.META['app']
        user = request.user.username
        channel = app.name
        count = get_subscriber_count(channel)
        try:
            body = json.loads(request.body)
            message = body["message"]
        except Exception:
            # body is probably urlencoded
            try:
                message = request.POST['message']
            except Exception:
                return Response("Invalid request. Check request format",
                                status=status.HTTP_400_BAD_REQUEST)

        push_to_channel(channel, message)
        notification = PushNotification(app=app, num_subscribers=count)
        notification.save()
        return Response({"result": count})
コード例 #2
0
ファイル: views.py プロジェクト: sushmasrai/CloudEngine
    def post(self, request):
        app = request.META['app']
        user = request.user.username
        channel = app.name
        count = get_subscriber_count(channel)
        try:
            body = json.loads(request.body)
            message = body["message"]
        except Exception:
            # body is probably urlencoded
            try:
                message = request.POST['message']
            except Exception:
                return Response("Invalid request. Check request format",
                                status=status.HTTP_400_BAD_REQUEST)

        push_to_channel(channel, message)
        notification = PushNotification(app=app, num_subscribers=count)
        notification.save()
        return Response({"result": count})
コード例 #3
0
ファイル: views.py プロジェクト: foulglory/CloudEngine
 def get(self, request):
     app = request.META['app']
     channel = app.name
     count = get_subscriber_count(channel)
     return Response({"result": count})
コード例 #4
0
ファイル: views.py プロジェクト: sushmasrai/CloudEngine
 def get(self, request):
     app = request.META['app']
     channel = app.name
     count = get_subscriber_count(channel)
     return Response({"result": count})