|
70 | 70 |
|
71 | 71 | BASE_DIR: Path = Path(__file__).resolve().parent |
72 | 72 |
|
73 | | -templates: Jinja2Templates = Jinja2Templates(directory=str(Path(BASE_DIR, "templates"))) |
| 73 | +templates: Jinja2Templates = Jinja2Templates( |
| 74 | + directory=str(Path(BASE_DIR, "templates"))) |
74 | 75 |
|
75 | 76 |
|
76 | 77 | @app.post("/file") |
@@ -126,8 +127,10 @@ async def get_paste_data(uuid: str, user_agent: Optional[str] = Header(None)) -> |
126 | 127 | try: |
127 | 128 | lexer = get_lexer_by_name(file_extension, stripall=True) |
128 | 129 | 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") |
131 | 134 | highlighted_code: str = highlight(content, lexer, formatter) |
132 | 135 | # print(highlighted_code) |
133 | 136 | custom_style = """ |
@@ -241,9 +244,11 @@ async def delete_paste(uuid: str) -> PlainTextResponse: |
241 | 244 | os.remove(path) |
242 | 245 | return PlainTextResponse(f"File successfully deleted {uuid}") |
243 | 246 | 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) |
245 | 249 | 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) |
247 | 252 |
|
248 | 253 |
|
249 | 254 | @app.get("/web", response_class=HTMLResponse) |
|
0 commit comments