views.py

# # I have Created This File  - Stark 

from django.http import HttpResponse
from django.shortcuts import render # for using templates in django we use this in our projects

## def index(request):
##     return HttpResponse("Hare Krishana  <h1> Haridas </h1>")
## def about(request):
##     return HttpResponse("Hare Krishana about wala")
## def index(request):
##     return "Krishna"

# def index(request): # it takes arguement request to perform the below task
     # return HttpResponse('''Tushar Haridas \n 
    
     # <a href="https://www.youtube.com/watch?v=AepgWsROO4k&list=PLu0W_9lII9ah7DDtYtflgwMwpT3xmjXY9&index=7" target = "_blank"> \nGo To the Django Playlist</a>
    
    
     # ''')

#     return HttpResponse("""Haridas
#          <button><a href="http://127.0.0.1:8000/about">Go To About</a>   
#          <button><a href="http://127.0.0.1:8000/removepunc">Go To removepunc</a>   
#          <button><a href="http://127.0.0.1:8000/capital">Go To capfirst</a>   
#          <button><a href="http://127.0.0.1:8000/new">Go To newlineremove</a>   
#          <button><a href="http://127.0.0.1:8000/space">Go To space</a>   
#          <button><a href="http://127.0.0.1:8000/char">Go To Charcount</a>   """)


# def about(request):
#     return HttpResponse("""About WAla hai
#         <button><a href="http://127.0.0.1:8000/">Back</a>   """)
    

    


# def removepunc(request):
#     return HttpResponse("""Remove Puncs
#     <button><a href="http://127.0.0.1:8000/">Back</a>""")

# def capfirst(request):
#     return HttpResponse("""Captalize First
#     <button><a href="http://127.0.0.1:8000/">Back</a>""")

# def newlineremove(request):
#     return HttpResponse("""newline remove first
#     <button><a href="http://127.0.0.1:8000/">Back</a>""")
# def spaceremove(request):
#     return HttpResponse("""Space removed
#     <button><a href="http://127.0.0.1:8000/">Back</a>""")

# def charcount(request):
#     return HttpResponse("""charcount
#     <button><a href="http://127.0.0.1:8000/">Back</a>""")
# # def a(request):

# #     with open("/textutils/textutils/1") as file
    
# #     # file = open("/1.txt","r+")
# #     # a = file.read()
# #     return HttpResponse("file.read <h1> %s</h1>%(file.read)")    

def index(request):
    params = {'name':"Tushar",'place':'mayapur'}
    return render(request,'index.html',params) 






//////////////////////////////////////////////////////




# I have Created This File  - Stark

# from django.http import HttpResponse
# from django.shortcuts import render # for using templates in django we use this in our projects

# def index(request):
#     return render(request,'index.html')

# def about(request):
#     return HttpResponse("TUshar <h1>Hare Krishna</h1>")

# so analyze.html is present in this blog so use that file for more information
from django.http import HttpResponse
# for using templates in django we use this in our projects
from django.shortcuts import render


def index(request):
    # st  = {'name':'Tushar','occu':'Stark'}
    return render(request, 'index.html')


def Analyze(request):

    # Get The Text
    # This will print the content of the string in the console
    djtext = request.GET.get('text', 'default')
    # This will print the content of the string in the console
    removepunc = request.GET.get('removepunc', 'OFF')
    # this will print value which is written in textarea and print it to the console
    print(djtext)
    # this will also work same but it print on value because we give parameter like removepunc
    print(removepunc)
    # Analyze the text
#    return HttpResponse("Tushar is the best and Haridas also")
    # analyzed_text = djtext
    if removepunc == 'on':

        Punctuations = '''/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"'''
        analyzed = ""
        for char in djtext:
            if char not in Punctuations:
                analyzed = analyzed+char
            else:
                None
                # analyzed = (analyzed+djtext+" ")

        param = {'purpose': "Removed Punctuations", 'analyzed_text': analyzed}
        return render(request, 'analyze.html', param)

    else:
        return HttpResponse("Error Man")



/////////////////////////////////////////////////
# I have Created This File  - Stark

# from django.http import HttpResponse
# from django.shortcuts import render # for using templates in django we use this in our projects

# def index(request):
#     return render(request,'index.html')

# def about(request):
#     return HttpResponse("TUshar <h1>Hare Krishna</h1>")


from django.http import HttpResponse
# for using templates in django we use this in our projects
from django.shortcuts import render


def index(request):
    # st  = {'name':'Tushar','occu':'Stark'}
    return render(request, 'index.html')

# def removepunc(request):


#     djtext = request.GET.get('text','default') # it returns the text which user enter in a field box and throws to console if not give the text then it print default
#     print(djtext)
#     return HttpResponse("remove punc first")

def Analyze(request):

    # it returns the text which user enter in a field box and throws to console if not give the text then it print default
    djtext = request.GET.get('text', 'default')
    removepunc = request.GET.get('removepunc', 'OFF')
    Fullcaps = request.GET.get('Fullcaps', 'OFF')
    NewLine = request.GET.get('NewLine', 'OFF')
    ExtraSpaceRemover = request.GET.get('ExtraSpaceRemover', 'OFF')
    CharactorCounter = request.GET.get('CharactorCounter', 'OFF')
    # print(removepunc)
    # print(djtext)
    if removepunc == "on":

        lists = '''(/[-[\]()*+{:?}.,\^$|#\s]/g,"\$&");'''
        ana = ""
        for char in djtext:
            if char not in lists:
                ana = ana+char
        # analyzed = ana
        params = {'purpose': "Removed Punctuations", 'analyzed_text': ana}
    # Analyze The text
        return render(request, 'analyze.html', params)
    elif(Fullcaps == "on"):

        ana = ""
        for char in djtext:

            ana = ana+char.upper()

        params = {'purpose': "Removed Punctuations", 'analyzed_text': ana}

        return render(request, 'analyze.html', params)

    elif(NewLine=="on"):
        ana = ""
        for char in djtext:
            if char!="\n":
                ana = ana+char

        params = {'purpose': "Removed NewLines", 'analyzed_text': ana}

        return render(request, 'analyze.html', params)
    elif(ExtraSpaceRemover=="on"):
        ana = ""
        for index,char in enumerate(djtext):
            if djtext[index]==" " and djtext[index+1]==" ":
                pass
            else:
                ana = ana+char

        params = {'purpose': "Removed NewLines", 'analyzed_text': ana}

        return render(request, 'analyze.html', params)
    elif(CharactorCounter=="on"):
        ana = ""
        counter=0
        for char,index in enumerate(djtext):
            if djtext[char]==" ":
                pass
            else:

                # counter = len(djtext)
                 counter = counter + 1


        params = {'purpose': "Counted Charactors", 'analyzed_text': counter}

        return render(request, 'analyze.html', params)
    else:
        return HttpResponse("Error Hai Bhai")













































Comments