This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For the implementation, it was used Python decorator in Django REST framework to define a view function that can handle HTTP requests. | |
@api_view(['GET']) | |
def getRakingRecomm(request): | |
category_arg = request.query_params.get('chosen_category') | |
# the ML model returns the id of 3 ranked recommended items based on the category selected on the search bar | |
# recommendation_dir = os.path.join(settings.BASE_DIR, 'm_l', 'recommendation') | |
# sys.path.append(recommendation_dir) | |
# from recommendation_f import create_ranking_df | |
id1, id2, id3 = create_ranking_df(category_arg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.parse | |
import requests | |
import urllib.parse | |
from urllib.parse import urlparse | |
url_search = 'https://geofree.pythonanywhere.com/api/get-categories/' | |
response2 = requests.get(url_search) | |
parsed_url = urlparse(url_search) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
import pandas as pd | |
import urllib.parse | |
import requests | |
from urllib.parse import urlparse | |
import json | |
import random | |
def create_ranking_df(chosen_category): |