34 lines
934 B
Python
34 lines
934 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(
|
|
level=logging.INFO,
|
|
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
|
datefmt="%Y-%m-%d %H:%M:%S",
|
|
)
|
|
|
|
@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) |