def get(self, request, *args, **kwargs): name1=request.GET.get('name1','rumcajsss') name2=request.GET.get('name2','msitake') template=Template(""" <html> <head> {% load staticfiles %} <link rel="stylesheet" type="text/css" href="{% static 'app/stylesheet.css' %}"/> <title>Comparision of top artists of two given users.</title> </head> <body> <div id="header"> <h3>Write names of LastFm users whose top artists you want to compare</h3> <form> User 1: <input type="text" name="name1"><br> User 2: <input type="text" name="name2"><br> <input type="submit" value="Submit"> </form> <h4>Common artists of {{ user1 }} and {{ user2 }} taken from Top20</h4> {% for artist in common_artists %} <p id="common"> {{ artist }} </p> {% endfor %} </div> <div id="left_column"> <h4>Artists of {{ user1 }}</h4> {% for artist in artists1 %} <p> {{ artist }} </p> {% endfor %} </div> <div id="right_column"> <h4>Artists of {{ user2 }}</h4> {% for artist in artists2 %} <p> {{ artist }} </p> {% endfor %} </div> </body> </html> """) user1=ArtistParser(name1) artists_list_1 = user1.downloadArtists() user2=ArtistParser(name2) artists_list_2 = user2.downloadArtists() comparison=Compare(artists_list_1,artists_list_2) common=comparison.checkCommon() dictionary={"artists1": artists_list_1, "artists2": artists_list_2, "common_artists": common, 'user1': name1, 'user2': name2} context1=Context(dictionary) return HttpResponse(template.render(context1))
def get(self, request, *args, **kwargs): name1=request.GET.get('name1','rumcajsss') name2=request.GET.get('name2','msitake') template=Template(""" <html> <head> <link rel="stylesheet" href="stylesheet.css"/> <title>Comparision of top artists of two given users.</title> </head> <body> <form>{% csrf_token %} User 1: <input type="text" name="name1"><br> User 2: <input type="text" name="name2"><br> <input type="submit" value="Submit"> </form> {% for artist in artists2 %} <h2> {{ artist }} </h2> {% endfor %} </body> </html> """) artists_list_1 = ArtistParser.downloadArtists(name1) artists_list_2 = ArtistParser.downloadArtists(name2) #print (artists_list) common_artists = Compare.checkCommon(artists_list_1, artists_list_2) # context1=Context(ArtistParser.downloadArtists(name1)) context1=Context({"artists1": artists_list_1}) context2=Context({"artists2": artists_list_2}) #return HttpResponse(template.render(context2)) return HttpResponse({"artists2" : common_artists}) #return HttpResponse(name1) #print (ArtistParser.download('rumcajsss')) #context = Context(ArtistParser.download(name1)) #return HttpResponse(template.render(context)) #zmienna = Compare.checkCommon(ArtistParser.downloadArtists('rumcajsss'), # ArtistParser.downloadArtists('msitake')) #return HttpResponse(ArtistParser.downloadArtists('rumcajsss')) #return HttpResponse(zmienna)