def get_channel_name_view(request):
    if (request.method == 'POST'):
        port = os.environ.get('PORT', 8000)
        form = ChannelNameForm(request.POST)
        if form.is_valid():
            config.CHANNEL = form.cleaned_data['channel_name']
            scope = ' '.join(settings.TOKEN_SCOPES)
            client_id = os.environ.get('TWITCH_APP_ID', None)
            url = f'https://id.twitch.tv/oauth2/authorize?client_id={client_id}&redirect_uri={settings.BASE_URL}/twitch-callback/&response_type=code&scope={scope}&force_verify=true'
            return HttpResponseRedirect(url)
        else:
            pass
    else:
        template = loader.get_template('registration/twitch-channel-setup.html')
        return HttpResponse(template.render({}, request))
def get_channel_name_view(request):
    if (request.method == 'POST'):
        port = os.environ.get('PORT', 8000)
        form = ChannelNameForm(request.POST)
        if form.is_valid():
            config.CHANNEL = form.cleaned_data['channel_name']
            scope = ' '.join(settings.TOKEN_SCOPES)
            client_id = os.environ.get('TWITCH_APP_ID', None)
            url = f'https://id.twitch.tv/oauth2/authorize?client_id={client_id}&redirect_uri={settings.BASE_URL}/twitch-callback/&response_type=code&scope={scope}&force_verify=true'
            return HttpResponseRedirect(url)
        else:
            pass
    else:
        template = loader.get_template('registration/twitch-channel-setup.html')
        return HttpResponse(template.render({}, request))