-
Notifications
You must be signed in to change notification settings - Fork 0
/
views.py
65 lines (51 loc) · 2.17 KB
/
views.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from django.http import HttpResponse
from django.shortcuts import render
def index(request):
return render(request, 'index.html')
def analyze(request):
# Get the text
djtext = request.GET.get('text', 'default')
# Check checkbox value
fullcaps = request.GET.get('fullcaps', 'off')
newlineremover = request.GET.get('newlineremover', 'off')
extraspaceremover = request.GET.get('extraspaceremover', 'off')
charactercount = request.GET.get('charactercount', 'off')
removepunc = request.GET.get('removepunc', 'off')
if removepunc == "on":
punctuations = '''!@#$%^&*()-_{}[]:;"'\|<>,.?/~`'''
analyzed = ""
for char in djtext:
if char not in punctuations:
analyzed = analyzed + char
params = {'purpose': 'Removed Punctuations', 'analyze_text': analyzed}
djtext = analyzed
if (fullcaps == "on"):
analyzed = " "
for char in djtext:
analyzed = analyzed + char.upper()
params = {'purpose': 'Change to Upper Case', 'analyze_text': analyzed}
djtext = analyzed
if (newlineremover == "on"):
analyzed = " "
for char in djtext:
if char != "\n":
analyzed = analyzed + char
params = {'purpose': 'New Line Remove', 'analyze_text': analyzed}
djtext = analyzed
if (extraspaceremover == "on"):
analyzed = ""
for index, char in enumerate(djtext):
if not (djtext[index] == " " and djtext[index + 1] == " "):
analyzed = analyzed + char
params = {'purpose': 'Extra Space Remove', 'analyze_text': analyzed}
djtext = analyzed
if (charactercount == "on"):
analyzed = djtext
analyzed = len(analyzed)
params = {'purpose': 'Number Of Character is :',
'analyze_text': analyzed}
if (
removepunc != "on" and fullcaps != "on" and newlineremover != "on" and extraspaceremover != "on" and charactercount != "on"):
return HttpResponse("Error..........")
return render(request, 'analyze.html', params)
# aktextutil.epizy.com