Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -37,8 +37,6 @@ def fetch_timetable_hour(eva, date_str, hour_str, client_id, api_key):
|
|
| 37 |
|
| 38 |
def get_connections(departure, destination, client_id, api_key):
|
| 39 |
"""Sucht die nächsten 3 Verbindungen ab jetzt."""
|
| 40 |
-
if not all([departure, destination]):
|
| 41 |
-
return None, "❌ Bitte alle Felder ausfüllen."
|
| 42 |
|
| 43 |
dep_info = get_station_info(departure, client_id, api_key)
|
| 44 |
dest_info = get_station_info(destination, client_id, api_key)
|
|
@@ -100,8 +98,8 @@ def format_markdown(connections):
|
|
| 100 |
|
| 101 |
return md
|
| 102 |
|
| 103 |
-
def main_interface(dep, dest,
|
| 104 |
-
conns, error = get_connections(dep, dest,
|
| 105 |
|
| 106 |
if error:
|
| 107 |
return error, json.dumps({"error": error}, indent=2)
|
|
@@ -119,11 +117,11 @@ def main_interface(dep, dest, client_id, api_key):
|
|
| 119 |
# --- Gradio UI ---
|
| 120 |
with gr.Blocks(title="DB Mobile Fahrplan", theme=gr.themes.Soft()) as demo:
|
| 121 |
gr.Markdown("# 📱 DB Quick-Check")
|
| 122 |
-
|
| 123 |
with gr.Accordion("⚙️ API-Konfiguration (Hier klicken)", open=False):
|
| 124 |
cid_input = gr.Textbox(label="DB Client ID", type="password")
|
| 125 |
akey_input = gr.Textbox(label="DB API Key", type="password")
|
| 126 |
-
|
| 127 |
with gr.Row():
|
| 128 |
dep_input = gr.Textbox(label="Von", placeholder="z.B. Berlin", scale=2)
|
| 129 |
dest_input = gr.Textbox(label="Nach", placeholder="z.B. Hamburg", scale=2)
|
|
@@ -138,7 +136,7 @@ with gr.Blocks(title="DB Mobile Fahrplan", theme=gr.themes.Soft()) as demo:
|
|
| 138 |
|
| 139 |
btn.click(
|
| 140 |
fn=main_interface,
|
| 141 |
-
inputs=[dep_input, dest_input],
|
| 142 |
outputs=[md_display, json_display]
|
| 143 |
)
|
| 144 |
|
|
@@ -146,13 +144,6 @@ if __name__ == "__main__":
|
|
| 146 |
demo.launch()
|
| 147 |
|
| 148 |
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
"""
|
| 157 |
import gradio as gr
|
| 158 |
import requests
|
|
|
|
| 37 |
|
| 38 |
def get_connections(departure, destination, client_id, api_key):
|
| 39 |
"""Sucht die nächsten 3 Verbindungen ab jetzt."""
|
|
|
|
|
|
|
| 40 |
|
| 41 |
dep_info = get_station_info(departure, client_id, api_key)
|
| 42 |
dest_info = get_station_info(destination, client_id, api_key)
|
|
|
|
| 98 |
|
| 99 |
return md
|
| 100 |
|
| 101 |
+
def main_interface(dep, dest, cid, akey):
|
| 102 |
+
conns, error = get_connections(dep, dest, cid, akey)
|
| 103 |
|
| 104 |
if error:
|
| 105 |
return error, json.dumps({"error": error}, indent=2)
|
|
|
|
| 117 |
# --- Gradio UI ---
|
| 118 |
with gr.Blocks(title="DB Mobile Fahrplan", theme=gr.themes.Soft()) as demo:
|
| 119 |
gr.Markdown("# 📱 DB Quick-Check")
|
| 120 |
+
|
| 121 |
with gr.Accordion("⚙️ API-Konfiguration (Hier klicken)", open=False):
|
| 122 |
cid_input = gr.Textbox(label="DB Client ID", type="password")
|
| 123 |
akey_input = gr.Textbox(label="DB API Key", type="password")
|
| 124 |
+
|
| 125 |
with gr.Row():
|
| 126 |
dep_input = gr.Textbox(label="Von", placeholder="z.B. Berlin", scale=2)
|
| 127 |
dest_input = gr.Textbox(label="Nach", placeholder="z.B. Hamburg", scale=2)
|
|
|
|
| 136 |
|
| 137 |
btn.click(
|
| 138 |
fn=main_interface,
|
| 139 |
+
inputs=[dep_input, dest_input, cid_input, akey_input],
|
| 140 |
outputs=[md_display, json_display]
|
| 141 |
)
|
| 142 |
|
|
|
|
| 144 |
demo.launch()
|
| 145 |
|
| 146 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
"""
|
| 148 |
import gradio as gr
|
| 149 |
import requests
|