Spaces:
Sleeping
Sleeping
Commit ·
fc2520f
1
Parent(s): 217053e
env
Browse files- .gitignore +2 -0
- app.py +4 -2
- test_api.py +1 -1
.gitignore
CHANGED
|
@@ -2,3 +2,5 @@
|
|
| 2 |
.venv
|
| 3 |
# pycache
|
| 4 |
__pycache__
|
|
|
|
|
|
|
|
|
| 2 |
.venv
|
| 3 |
# pycache
|
| 4 |
__pycache__
|
| 5 |
+
# .env
|
| 6 |
+
.env
|
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import requests
|
| 2 |
from flask import Flask, request, jsonify
|
| 3 |
from flask_cors import CORS
|
|
@@ -6,6 +7,7 @@ from tempfile import NamedTemporaryFile
|
|
| 6 |
|
| 7 |
app = Flask(__name__)
|
| 8 |
CORS(app)
|
|
|
|
| 9 |
|
| 10 |
# Function to download data from API and save to a temporary file
|
| 11 |
def download_and_save_data(url: str) -> str:
|
|
@@ -17,8 +19,8 @@ def download_and_save_data(url: str) -> str:
|
|
| 17 |
return tmp_file.name
|
| 18 |
|
| 19 |
# URLs for the data
|
| 20 |
-
films_url = '
|
| 21 |
-
tv_series_url = '
|
| 22 |
|
| 23 |
# Download and save data
|
| 24 |
films_file = download_and_save_data(films_url)
|
|
|
|
| 1 |
+
import os
|
| 2 |
import requests
|
| 3 |
from flask import Flask, request, jsonify
|
| 4 |
from flask_cors import CORS
|
|
|
|
| 7 |
|
| 8 |
app = Flask(__name__)
|
| 9 |
CORS(app)
|
| 10 |
+
LOAD_BALANCER_URL = os.getenv("LOAD_BALANCER_URL")
|
| 11 |
|
| 12 |
# Function to download data from API and save to a temporary file
|
| 13 |
def download_and_save_data(url: str) -> str:
|
|
|
|
| 19 |
return tmp_file.name
|
| 20 |
|
| 21 |
# URLs for the data
|
| 22 |
+
films_url = f'{LOAD_BALANCER_URL}/api/film/all'
|
| 23 |
+
tv_series_url = f'{LOAD_BALANCER_URL}/api/tv/all'
|
| 24 |
|
| 25 |
# Download and save data
|
| 26 |
films_file = download_and_save_data(films_url)
|
test_api.py
CHANGED
|
@@ -2,7 +2,7 @@ import requests
|
|
| 2 |
import json
|
| 3 |
|
| 4 |
# Define the API endpoint
|
| 5 |
-
url = "
|
| 6 |
|
| 7 |
# Define the search queries you want to test
|
| 8 |
test_queries = [
|
|
|
|
| 2 |
import json
|
| 3 |
|
| 4 |
# Define the API endpoint
|
| 5 |
+
url = "https://unicone-studio-search.hf.space/api/search"
|
| 6 |
|
| 7 |
# Define the search queries you want to test
|
| 8 |
test_queries = [
|