Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 15 additions & 34 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,21 @@
import os
import logging
from contextlib import asynccontextmanager

from fastapi import FastAPI
import sentry_sdk

from app.api import text_extract, pdf_extract # updated
sentry_sdk.init(
dsn="https://5c74c0bf64424183a3d8fea7a803a9b0@o4505535984828416.ingest.sentry.io/4505535986335744",
traces_sample_rate=1.0,
profiles_sample_rate=1.0,
profiles_sampler=1.0,
)

log = logging.getLogger("uvicorn")
from pydantic import BaseModel
import uvicorn

@asynccontextmanager
async def lifespan(app: FastAPI):
log.info("Starting up...")
yield
log.info("Shutting down...")
app = FastAPI()

def create_application() -> FastAPI:
application = FastAPI(
title="API_OCR",
version="0.1.0",
description="OCR API project using tesseract and fastapi",
contact={
"name": "Fabio",
},
lifespan=lifespan
)
application.include_router(text_extract.router)
application.include_router(pdf_extract.router)
class Item(BaseModel):
name: str
description: str | None = None
price: float

return application
@app.get('/')
def read_root():
return {'message': 'Welcome to the FastAPI app!'}

@app.post('/items/')
def create_item(item: Item):
return item

app = create_application()
if __name__ == '__main__':
uvicorn.run('main:app', host='127.0.0.1', port=8000, reload=True)
6 changes: 6 additions & 0 deletions app/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from pydantic import BaseModel

class Item(BaseModel):
name: str
description: str | None = None
price: float
Loading