Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@ import gradio as gr
|
|
| 2 |
import requests
|
| 3 |
from bs4 import BeautifulSoup
|
| 4 |
|
| 5 |
-
#
|
| 6 |
def get_epic_free_games():
|
| 7 |
try:
|
| 8 |
url = "https://store-site-backend-static.ak.epicgames.com/freeGamesPromotions?locale=en-US"
|
|
@@ -24,7 +24,7 @@ def get_epic_free_games():
|
|
| 24 |
except Exception as e:
|
| 25 |
return [f"โ Error fetching Epic Games: {e}"]
|
| 26 |
|
| 27 |
-
#
|
| 28 |
def get_steam_games():
|
| 29 |
try:
|
| 30 |
url = "https://isthereanydeal.com/giveaways/"
|
|
@@ -54,7 +54,7 @@ def get_steam_games():
|
|
| 54 |
except Exception as e:
|
| 55 |
return [], [f"โ Steam error: {e}"]
|
| 56 |
|
| 57 |
-
#
|
| 58 |
def generate_free_game_data():
|
| 59 |
epic = get_epic_free_games()
|
| 60 |
steam_imgs, steam_info = get_steam_games()
|
|
@@ -69,22 +69,31 @@ def generate_free_game_data():
|
|
| 69 |
|
| 70 |
return steam_imgs, full_text, "free_games.txt"
|
| 71 |
|
| 72 |
-
#
|
| 73 |
-
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 74 |
-
gr.
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
Click below to start scanning ๐
|
| 80 |
""")
|
| 81 |
|
| 82 |
-
|
|
|
|
| 83 |
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
btn.click(fn=generate_free_game_data, inputs=[], outputs=[gallery, summary, file])
|
| 89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
demo.launch()
|
|
|
|
| 2 |
import requests
|
| 3 |
from bs4 import BeautifulSoup
|
| 4 |
|
| 5 |
+
# Epic Games
|
| 6 |
def get_epic_free_games():
|
| 7 |
try:
|
| 8 |
url = "https://store-site-backend-static.ak.epicgames.com/freeGamesPromotions?locale=en-US"
|
|
|
|
| 24 |
except Exception as e:
|
| 25 |
return [f"โ Error fetching Epic Games: {e}"]
|
| 26 |
|
| 27 |
+
# Steam Games
|
| 28 |
def get_steam_games():
|
| 29 |
try:
|
| 30 |
url = "https://isthereanydeal.com/giveaways/"
|
|
|
|
| 54 |
except Exception as e:
|
| 55 |
return [], [f"โ Steam error: {e}"]
|
| 56 |
|
| 57 |
+
# Combined Function
|
| 58 |
def generate_free_game_data():
|
| 59 |
epic = get_epic_free_games()
|
| 60 |
steam_imgs, steam_info = get_steam_games()
|
|
|
|
| 69 |
|
| 70 |
return steam_imgs, full_text, "free_games.txt"
|
| 71 |
|
| 72 |
+
# Gradio App
|
| 73 |
+
with gr.Blocks(theme=gr.themes.Soft(primary_hue="purple")) as demo:
|
| 74 |
+
gr.HTML("""
|
| 75 |
+
<div style="text-align: center; padding: 2rem 1rem;">
|
| 76 |
+
<h1 style="font-size: 2.5rem; margin-bottom: 0.5rem;">๐น๏ธ Free Game Radar</h1>
|
| 77 |
+
<p style="font-size: 1.1rem; color: #555;">Automatically find and display daily free games from Epic, Steam, and more.</p>
|
| 78 |
+
</div>
|
|
|
|
| 79 |
""")
|
| 80 |
|
| 81 |
+
with gr.Row():
|
| 82 |
+
btn = gr.Button("๐ฎ Scan for Free Games", variant="primary")
|
| 83 |
|
| 84 |
+
with gr.Row():
|
| 85 |
+
gallery = gr.Gallery(label="๐ข Steam Game Covers", columns=2, height="auto", show_label=True)
|
| 86 |
+
|
| 87 |
+
summary = gr.Textbox(label="๐ Game Summary", lines=20, interactive=False)
|
| 88 |
+
|
| 89 |
+
file = gr.File(label="โฌ๏ธ Download Game List (.txt)", interactive=False)
|
| 90 |
|
| 91 |
btn.click(fn=generate_free_game_data, inputs=[], outputs=[gallery, summary, file])
|
| 92 |
|
| 93 |
+
gr.HTML("""
|
| 94 |
+
<div style="text-align: center; font-size: 0.9rem; color: #777; padding: 2rem 0;">
|
| 95 |
+
Made with ๐ป by [Your Name] โข Powered by Python & Hugging Face
|
| 96 |
+
</div>
|
| 97 |
+
""")
|
| 98 |
+
|
| 99 |
demo.launch()
|