From 6c4a69c8fc0635140ed2cf589cb87397cd9e8e87 Mon Sep 17 00:00:00 2001 From: Kyle K Date: Mon, 27 Mar 2017 03:14:49 -0500 Subject: use templating to render HTML page on /app --- myapp/templates/index.html | 37 +++++++++++++++++++++++++++++++++++++ myapp/views.py | 4 +++- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 myapp/templates/index.html (limited to 'myapp') diff --git a/myapp/templates/index.html b/myapp/templates/index.html new file mode 100644 index 0000000..1a1f618 --- /dev/null +++ b/myapp/templates/index.html @@ -0,0 +1,37 @@ + + + + + Craigslist Scraper + + + +

Craigslist Scrapper

+get list of current WRX STi parts for sale in Chicago area +
+    url: {{ baseurl }}
+    query: {{ keyword }}
+
+    author: fatalhalt
+    https://github.com/fatalhalt/CLscrap
+
+
+
+{% for i in data %} +
+ {{ i.title }} + {{ i.date }} + {{ i.price }} + {{ i.hood }} + img +
+{% endfor %} +
+ + \ No newline at end of file diff --git a/myapp/views.py b/myapp/views.py index 6b014ac..600a061 100644 --- a/myapp/views.py +++ b/myapp/views.py @@ -2,11 +2,13 @@ from django.shortcuts import render # Create your views here. from django.http import HttpResponse, JsonResponse +from django.shortcuts import render import cl def app(request): - return HttpResponse("hello, app!") + data, baseurl, keyword = cl.query_craigslist() + return render(request, 'index.html', {'data': data, 'baseurl': baseurl, 'keyword': keyword}) def page(request): -- cgit v1.2.3