Skip to content

Instantly share code, notes, and snippets.

View KC2016's full-sized avatar
🐙
always learning

KarinaC KC2016

🐙
always learning
  • KC2016.github.io
View GitHub Profile
# 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)
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)
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):