Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,34 +1,45 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
import requests
|
3 |
-
from ytmusicapi import YTMusic
|
4 |
|
5 |
-
ytmusic = YTMusic()
|
6 |
|
7 |
-
# Function to fetch search results from the API
|
8 |
-
def fetch_search_results(query):
|
9 |
-
|
10 |
-
|
11 |
|
12 |
-
# Main Streamlit app
|
13 |
-
def main():
|
14 |
-
|
15 |
|
16 |
-
|
17 |
-
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
1 |
+
# import streamlit as st
|
2 |
+
# import requests
|
3 |
+
# from ytmusicapi import YTMusic
|
4 |
|
5 |
+
# ytmusic = YTMusic()
|
6 |
|
7 |
+
# # Function to fetch search results from the API
|
8 |
+
# def fetch_search_results(query):
|
9 |
+
# results = ytmusic.search(query)
|
10 |
+
# return results
|
11 |
|
12 |
+
# # Main Streamlit app
|
13 |
+
# def main():
|
14 |
+
# st.title("YouTube Music Search")
|
15 |
|
16 |
+
# # Search bar
|
17 |
+
# search_query = st.text_input("Enter your search query:", "")
|
18 |
|
19 |
+
# # Button to trigger search
|
20 |
+
# if st.button("Search"):
|
21 |
+
# if search_query:
|
22 |
+
# # Fetch search results
|
23 |
+
# results = fetch_search_results(search_query)
|
24 |
+
# if results:
|
25 |
+
# st.write("Search Results:")
|
26 |
+
# for result in results:
|
27 |
+
# st.write(result)
|
28 |
+
# else:
|
29 |
+
# st.error("Failed to fetch search results. Please try again later.")
|
30 |
+
# else:
|
31 |
+
# st.warning("Please enter a search query.")
|
32 |
+
|
33 |
+
# if __name__ == "__main__":
|
34 |
+
# main()
|
35 |
+
from flask import Flask, request, jsonify
|
36 |
+
from ytmusicapi import YTMusic
|
37 |
+
import streamlit as st
|
38 |
+
app = Flask(__name__)
|
39 |
+
ytmusic = YTMusic()
|
40 |
|
41 |
+
@app.route("/search/")
|
42 |
+
def search():
|
43 |
+
query = request.args.get('query')
|
44 |
+
search_results = ytmusic.search(query)
|
45 |
+
return jsonify(search_results)
|