Skip to content

Commit 34f1432

Browse files
committed
refactor: add formatting
1 parent 9f16ad8 commit 34f1432

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/paste/main.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@
7070

7171
BASE_DIR: Path = Path(__file__).resolve().parent
7272

73-
templates: Jinja2Templates = Jinja2Templates(directory=str(Path(BASE_DIR, "templates")))
73+
templates: Jinja2Templates = Jinja2Templates(
74+
directory=str(Path(BASE_DIR, "templates")))
7475

7576

7677
@app.post("/file")
@@ -126,8 +127,10 @@ async def get_paste_data(uuid: str, user_agent: Optional[str] = Header(None)) ->
126127
try:
127128
lexer = get_lexer_by_name(file_extension, stripall=True)
128129
except ClassNotFound:
129-
lexer = get_lexer_by_name("text", stripall=True) # Default lexer
130-
formatter = HtmlFormatter(style="colorful", full=True, linenos="inline", cssclass="code")
130+
lexer = get_lexer_by_name(
131+
"text", stripall=True) # Default lexer
132+
formatter = HtmlFormatter(
133+
style="colorful", full=True, linenos="inline", cssclass="code")
131134
highlighted_code: str = highlight(content, lexer, formatter)
132135
# print(highlighted_code)
133136
custom_style = """
@@ -241,9 +244,11 @@ async def delete_paste(uuid: str) -> PlainTextResponse:
241244
os.remove(path)
242245
return PlainTextResponse(f"File successfully deleted {uuid}")
243246
except FileNotFoundError:
244-
raise HTTPException(detail="File Not Found", status_code=status.HTTP_404_NOT_FOUND)
247+
raise HTTPException(detail="File Not Found",
248+
status_code=status.HTTP_404_NOT_FOUND)
245249
except Exception as e:
246-
raise HTTPException(detail=f"The exception is {e}", status_code=status.HTTP_409_CONFLICT)
250+
raise HTTPException(
251+
detail=f"The exception is {e}", status_code=status.HTTP_409_CONFLICT)
247252

248253

249254
@app.get("/web", response_class=HTMLResponse)

0 commit comments

Comments
 (0)