mirror of
https://github.com/henry4682/linebot_finance.git
synced 2026-05-16 04:41:52 +00:00
feat: linbot
restruct the project
This commit is contained in:
22
app/Invoice/Router.py
Normal file
22
app/Invoice/Router.py
Normal file
@@ -0,0 +1,22 @@
|
||||
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"}
|
||||
Reference in New Issue
Block a user