File size: 1,050 Bytes
9dd175d
 
 
 
 
 
 
 
 
 
fc13725
 
9dd175d
ad07916
9dd175d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# app.py

# from flask import Flask,request,jsonify
# from flask_cors import CORS
from fastapi import FastAPI
# loading the data from the csv file to apandas dataframe
app = FastAPI()
from huggingface_hub import login

import os
cache_dir = '/tmp/hf_cache'
os.makedirs(cache_dir, exist_ok=True)
# Login with token from environment
# login(token=os.getenv("HF_TOKEN"),cache_dir=cache_dir)
# app = Flask(__name__)
# cors = CORS(app, resources={r"*": {"origins": "*"}})
from recommendwithhist import recommend_movieswithhistory
from recommendwithdesc import recommend_movies_with_desc
from recommend_normal import recommend_movies
# Define a route for the home page

@app.get('/')
def hello_world(username: str, movie: str):
    return recommend_movieswithhistory(username, movie)

# Description-based recommendation
@app.get('/des')
def test(desc: str):
    return recommend_movies_with_desc([desc])

# Normal movie search
@app.get('/search')
def normal(movie: str):
    return recommend_movies(movie)
# Run the app if the script is executed directly