Spaces:
Sleeping
Sleeping
Download app.py from petenathaphat/ppanalyst: direct link, hf CLI and curl.
- Browser
- Download file 1.28 kB
-
https://huggingface.co/spaces/petenathaphat/ppanalyst/resolve/main/app.py
- Command line
-
hf download hf://spaces/petenathaphat/ppanalyst/app.py
-
curl -L -o app.py https://huggingface.co/spaces/petenathaphat/ppanalyst/resolve/main/app.py
1.28 kB
| import gradio as gr | |
| from analyzer import analyze_pretty | |
| def do_analyze(ticker_input: str): | |
| t = (ticker_input or "").strip().upper() | |
| if not t: | |
| return "โปรดพิมพ์สัญลักษณ์หุ้นก่อนครับ (เช่น: NVDA, TSLA, AMD)" | |
| try: | |
| return analyze_pretty(t) | |
| except Exception as e: | |
| return f"เกิดข้อผิดพลาดในการวิเคราะห์: {e}" | |
| with gr.Blocks(title="PP Stock – Analyzer", theme=gr.themes.Soft()) as demo: | |
| gr.Markdown("## PP Stock – ที่ปรึกษาการลงทุนของคุณ\nพิมพ์สัญลักษณ์แล้วกด **Analyze** หรือกด Enter") | |
| txt = gr.Textbox( | |
| label="พิมพ์สัญลักษณ์ (เช่น: TSLA, NVDA, AMD)", | |
| placeholder="เช่น NVDA", | |
| lines=1, | |
| ) | |
| btn = gr.Button("Analyze", variant="primary") | |
| out = gr.Textbox(label="ผลการวิเคราะห์", lines=26, show_copy_button=True) | |
| btn.click(fn=do_analyze, inputs=txt, outputs=out) | |
| txt.submit(fn=do_analyze, inputs=txt, outputs=out) # รองรับกด Enter | |
| if __name__ == "__main__": | |
| demo.launch() | |