30 lines
862 B
Python
30 lines
862 B
Python
import logging
|
|
from starlette.requests import Request
|
|
from starlette.responses import Response
|
|
import uvicorn
|
|
from fastapi import FastAPI, Form, UploadFile, File
|
|
import ntfy_service
|
|
|
|
from converter import read_brokerage_pdf, read_dividends_xlsx
|
|
import io
|
|
app = FastAPI()
|
|
|
|
logger = logging.getLogger(__name__)
|
|
logging.basicConfig(filename='rico-to-ghostfolio.log', level=logging.INFO)
|
|
|
|
@app.post("/brokerage")
|
|
async def convert_pdf(file: UploadFile = File(...)):
|
|
return read_brokerage_pdf(file)
|
|
|
|
@app.post("/b3dividends")
|
|
async def convert_pdf(file: UploadFile = File(...)):
|
|
return read_dividends_xlsx(file)
|
|
|
|
@app.post("/notification")
|
|
async def notification(request: Request):
|
|
message = await request.body()
|
|
return ntfy_service.send_notification(message.decode('utf8'))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
uvicorn.run(app, host="0.0.0.0", port=8000) |