mirror of
https://github.com/henry4682/linebot_finance.git
synced 2026-05-16 04:41:52 +00:00
22 lines
502 B
Python
Executable File
22 lines
502 B
Python
Executable File
import asyncio
|
|
import threading
|
|
from fastapi import APIRouter
|
|
|
|
router = APIRouter(prefix="/Invoice")
|
|
|
|
|
|
def _run_fetch():
|
|
from invoice_fetcher import main as fetch_main
|
|
loop = asyncio.new_event_loop()
|
|
asyncio.set_event_loop(loop)
|
|
try:
|
|
loop.run_until_complete(fetch_main())
|
|
finally:
|
|
loop.close()
|
|
|
|
|
|
@router.get("/fetch")
|
|
async def fetch_invoices():
|
|
print("🚀 開始抓取發票...")
|
|
threading.Thread(target=_run_fetch).start()
|
|
return {"status": "started"} |