-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviews.py
More file actions
103 lines (67 loc) · 2.7 KB
/
Copy pathviews.py
File metadata and controls
103 lines (67 loc) · 2.7 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
from django.shortcuts import render, redirect, get_object_or_404, HttpResponseRedirect
from .models import Acu, Insurance
from .forms import AcuForm
from .forms import InsuranceForm
import requests
from bs4 import BeautifulSoup
# Create your views here.
def index(request):
clinics = Acu.objects.all()
return render(request, 'Acu_Insurance/index.html', {'clinics': clinics})
def home(request):
return render(request, 'Acu_Insurance/Acu_Insurance_home.html')
def thanks(request):
return render(request, 'Acu_Insurance/Acu_Insurance_Thanks.html')
def add(request):
form = AcuForm(request.POST or None)
if request.method == 'POST':
form = AcuForm(request.POST or None)
if form.is_valid():
form.save()
return redirect('index')
context = {'form': form, }
return render(request, 'Acu_Insurance/Acu_Insurance_add.html', context)
def addInsurance(request):
if request.method == 'POST':
forms = InsuranceForm(request.POST)
if forms.is_valid():
forms.save()
return redirect('Thanks')
else:
forms = InsuranceForm()
return render(request, 'Acu_Insurance/Acu_Insurance_addInsurance.html', {'forms': forms})
def details(request, pk):
clinic = get_object_or_404(Acu, pk=pk)
context = {'clinic': clinic}
return render(request, 'Acu_Insurance/Acu_Insurance_details.html', context)
def edit(request, pk):
clinic = get_object_or_404(Acu, pk=pk)
if request.method == "POST":
form = AcuForm(request.POST, instance=clinic)
if form.is_valid():
form.save()
return redirect('details', pk=clinic.pk)
else:
form = AcuForm(instance=clinic)
return render(request, 'Acu_Insurance/Acu_Insurance_edit.html', {'form': form})
def delete(request, pk):
clinic = get_object_or_404(Acu, pk=pk)
if request.method == 'POST':
clinic.delete()
return redirect('index')
context = {'clinic': clinic}
return render(request, 'Acu_Insurance/Acu_Insurance_delete.html', context)
def latest(request):
page = requests.get("https://news.harvard.edu/gazette/story/2020/08/study-reveals-acupuncture-affects-disease-course/")
soup = BeautifulSoup(page.content, 'html.parser')
# match = soup.title.text
# print(match)
# match = soup.div
# print(match)
# match = soup.find('div')
# print(match)
article = soup.find('div', class_='article-body basic-text do-drop-cap')
# print(article)
# text = article.p
# print(text)
for p in soup.find_all('p', class_='article-body basic-text do-drop-cap'):