docker
This commit is contained in:
20
.vscode/launch.json
vendored
Normal file
20
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
|
||||
{
|
||||
"name": "Python Debugger: FastAPI",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"module": "uvicorn",
|
||||
"args": [
|
||||
"main:app",
|
||||
"--reload"
|
||||
],
|
||||
"jinja": true
|
||||
}
|
||||
]
|
||||
}
|
||||
10
Dockerfile
Normal file
10
Dockerfile
Normal file
@@ -0,0 +1,10 @@
|
||||
FROM python:3.14
|
||||
|
||||
WORKDIR /code
|
||||
COPY ./requirements.txt /code/requirements.txt
|
||||
|
||||
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
||||
|
||||
COPY . /code/
|
||||
|
||||
CMD ["fastapi", "run", "app/main.py", "--port", "80"]
|
||||
21
convert_to_json.py
Normal file
21
convert_to_json.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from fastapi import UploadFile
|
||||
from correpy.parsers.brokerage_notes.parser_factory import ParserFactory
|
||||
import logging
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Check if requires password based on file name
|
||||
async def open_file(file: UploadFile):
|
||||
|
||||
brokerage_notes = None
|
||||
|
||||
# Rico
|
||||
if "11775539" in file.filename:
|
||||
logger.info("[convert_to_json] Reading Rico notes")
|
||||
#brokerage_notes = ParserFactory(brokerage_note=content, password=RICO_PASSW).parse()
|
||||
|
||||
|
||||
print(brokerage_notes)
|
||||
9
docker-compose.yml
Normal file
9
docker-compose.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
services:
|
||||
brokerage-note-converter:
|
||||
container_name: brokerage-note-converter
|
||||
build: .
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- "8000:80"
|
||||
restart: unless-stopped
|
||||
|
||||
23
main.py
23
main.py
@@ -1,13 +1,28 @@
|
||||
from fastapi import FastAPI
|
||||
from fastapi import FastAPI, File, UploadFile
|
||||
import logging
|
||||
from correpy.parsers.brokerage_notes.parser_factory import ParserFactory
|
||||
|
||||
|
||||
logging.basicConfig()
|
||||
logger = logging.getLogger('uvicorn.error')
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
RICO_PASSW = "052"
|
||||
|
||||
@app.get("/")
|
||||
def read_root():
|
||||
return {"Hello": "World"}
|
||||
|
||||
|
||||
@app.get("/test")
|
||||
def test():
|
||||
return "Test"
|
||||
@app.post("/convert-brokerage-note")
|
||||
async def convert_brokerage_note(file: UploadFile):
|
||||
|
||||
content = file.file.read()
|
||||
|
||||
if "11775539" in file.filename:
|
||||
logger.info("Parsing Rico note")
|
||||
brokerage_notes = ParserFactory(brokerage_note=content, password=RICO_PASSW).parse()
|
||||
|
||||
|
||||
return {"fileName": file.filename, "result": brokerage_notes}
|
||||
BIN
test/NotaNegociacao-11775539-04-11-2025-0.pdf
Normal file
BIN
test/NotaNegociacao-11775539-04-11-2025-0.pdf
Normal file
Binary file not shown.
Reference in New Issue
Block a user