forked from Luanarm/Rememberescence
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.py
More file actions
33 lines (28 loc) · 1007 Bytes
/
client.py
File metadata and controls
33 lines (28 loc) · 1007 Bytes
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
import requests
import json
# Define the Flask server URL
SERVER_URL = "http://127.0.0.1:5000"
def generate_content(interests, location, age, genre):
# Define the request payload
payload = {
"interests": interests,
"location": location,
"age": age,
"genre": genre
}
# Send a POST request to the Flask server's /generate endpoint
response = requests.post(f"{SERVER_URL}/generate", json=payload)
# Check if the request was successful
if response.status_code == 200:
data = response.json()
print("Generated Content:")
print(data.get("generated_content"))
if data.get("playlist_created"):
print("Playlist created successfully!")
else:
print("Playlist creation failed.")
else:
print("Failed to generate content. Status code:", response.status_code)
if __name__ == "__main__":
# Example usage
generate_content("legos, beyblade, star wars", "Canada", "30", "rock")