<commit_before>from django.http import HttpRequest
from django.views.generic import TemplateView
from rest_framework.response import Response
from rest_framework.utils import json
from rest_framework.views import APIView

from life3.user.user_service import UserService


class LoginHome(TemplateView):
    """
    Login template
    """
    template_name = 'login.html'


class LoginApi(APIView):

    def post(self, request: HttpRequest):
        """
        Create user from profile based on OAuth.
        If user already exists or token has expired, update user from profile

        :param request: HttpRequest
        :return: JSON response
        """

        profile: dict = json.loads(request.body)

        message = 'success'
        # userId, userName, accessToken, type
        if profile['userId']:
            if UserService.is_valid_user(profile['userId']):
                UserService.update_user_profile(profile)
            else:
                UserService.create_user_profile(profile)
        else:
            message = 'userId is empty!'

        return Response({'result', message})

    def get(self):
        return Response({'result', 'unsupported request'})<commit_msg>syntax error correction<commit_after>from django.http import HttpRequest
from django.views.generic import TemplateView
from rest_framework.response import Response
from rest_framework.utils import json
from rest_framework.views import APIView

from life3.user.user_service import UserService


class LoginHome(TemplateView):
    """
    Login template
    """
    template_name = 'login.html'


class LoginApi(APIView):

    def post(self, request: HttpRequest):
        """
        Create user from profile based on OAuth.
        If user already exists or token has expired, update user from profile

        :param request: HttpRequest
        :return: JSON response
        """

        profile: dict = json.loads(request.body)

        message = 'success'
        # userId, userName, accessToken, type
        if profile['userId']:
            if UserService.is_valid_user(profile['userId']):
                UserService.update_user_profile(profile)
            else:
                UserService.create_user_profile(profile)
        else:
            message = 'userId is empty!'

        return Response({'result': message})

    def get(self):
        return Response({'result': 'unsupported request'})
{'fraction_non_alphanumeric': 0.08388704318936877, 'fraction_numerical': 0.0008305647840531562, 'mean_word_length': 2.7348837209302324, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4186055', 'n_tokens_mistral': 620, 'n_tokens_neox': 606, 'n_words': 183}