commit 6

swadhinbiswas committed 2 years ago
2feead2
1 parent b4adfb2
commit 2feead2
12 files changed
+21 -55
▼api/v1/handlers/__pycache__/handler.cpython-311.pyc
+0-0
Binary file not shown.
▼api/v1/handlers/handler.py
+12-5
1
1
from fastapi import APIRouter,HTTPException,UploadFile,File
2
-from services import pdftoword
2
+from fastapi.responses import JSONResponse
3
+
3
4
import pymongo
4
5
from schemas import articleschema
5
-
6
+import shutil
7
+from pathlib import Path
8
+from tempfile import NamedTemporaryFile
9
+from typing import Callable
6
10
7
11
routerx=APIRouter()
8
12
9
13
@routerx.post("/aticle",response_model=articleschema.ArticleOut)
10
-async def store_article():
11
- pass
12
-
14
+async def create_upload_file(uploaded_file: UploadFile = File(...)):
15
+ file_location = f"files/{uploaded_file.filename}"
16
+ with open(file_location, "wb+") as file_object:
17
+ file_object.write(uploaded_file.file.read())
18
+ return {"info": f"file '{uploaded_file.filename}' saved at '{file_location}'"}
19
+
13
20
▼models/__init__.py
+1-0
1
+from TheProfessor import models
0
2
▼models/studentmodel.py
+4-4
2
2
from typing import Any, Optional
3
3
from datetime import datetime
4
4
from uuid import UUID,uuid4
5
-from beanie import Document, Indexed
5
+from beanie import Document,Indexed
6
6
7
7
class Student(Document):
8
8
user_id: UUID = Indexed(default_factory=uuid4)
9
- student_id:Indexed(str,unique=True)
9
+ student_id:Indexed(str,unique=True) # type: ignore
10
10
first_name: Optional[str] = None
11
11
last_name: Optional[str] = None
12
- user_name:Indexed(str,unique=True)
13
- email:Indexed(str,unique=True)
12
+ user_name:Indexed(str,unique=True) # type: ignore
13
+ email:Indexed(str,unique=True) # type: ignore
14
14
hashed_password: str
15
15
is_active:Optional[bool] = True
16
16
is_superuser: Optional[bool] = False
17
17
▼routes/Untitled-1.json
+0-45
1
-{
2
- "editor.fontFamily": "Fira Code",
3
- "editor.fontLigatures": true,
4
- "editor.fontSize": 18,
5
- "editor.fontWeight": "500",
6
-
7
- "terminal.integrated.fontFamily": "MesloLGS NF",
8
- "terminal.integrated.fontWeightBold": "bold",
9
- "terminal.integrated.enableImages": true,
10
- "terminal.integrated.fontSize": 18,
11
- "terminal.external.linuxExec": "",
12
- "terminal.integrated.cursorStyleInactive": "line",
13
- "terminal.integrated.cursorWidth": 2,
14
- "terminal.integrated.defaultProfile.windows": "Monokai Pro",
15
- "workbench.colorTheme": "Dracula",
16
- "workbench.iconTheme": "material-icon-theme",
17
- "git.autofetch": true,
18
- "explorer.confirmDelete": false,
19
- "files.autoSave": "afterDelay",
20
- "editor.formatOnSave": true,
21
- "workbench.productIconTheme": "fluent-icons",
22
- "php.validate.executablePath": "",
23
- "terminal.integrated.inheritEnv": false,
24
-
25
- "editor.minimap.enabled": false,
26
- "editor.wordWrap": "on",
27
- "editor.tabSize": 2,
28
-
29
- "editor.renderWhitespace": "all",
30
- "editor.renderControlCharacters": true,
31
- "editor.renderLineHighlight": "all",
32
-
33
- "[markdown]": {
34
- "files.autoSave": "afterDelay"
35
- },
36
- "editor.guides.indentation": true,
37
- "diffEditor.ignoreTrimWhitespace": false,
38
- "diffEditor.hideUnchangedRegions.enabled": true,
39
- "explorer.confirmDragAndDrop": false,
40
- "jupyter.enableExtendedPythonKernelCompletions": true,
41
- "python.analysis.enableSyncServer": true,
42
- "python.autoComplete.extraPaths": [],
43
- "python.envFile": "",
44
- "python.analysis.extraPaths": []
45
-}
46
0
▼routes/__pycache__/routers.cpython-311.pyc
+0-0
Binary file not shown.
▼routes/__pycache__/routersapp.cpython-311.pyc
+0-0
Binary file not shown.
▼routes/routersapp.py
+2-1
1
1
from fastapi import APIRouter, HTTPException, status
2
-from api.v1.handlers import plaguehandel,teacherpannel
2
+from api.v1.handlers import plaguehandel,teacherpannel,handler
3
3
4
4
app_router=APIRouter()
5
5
6
6
app_router.include_router(plaguehandel.router,prefix='/plagures',tags=["plagures"])
7
7
app_router.include_router(teacherpannel.teacher_router,prefix='/teachers',tags=["teachers"])
8
+app_router.include_router(handler.routerx,prefix='/uplaodpf',tags=["uploadpdf"])
8
9
9
10
▼schemas/__pycache__/articleschema.cpython-311.pyc
+0-0
Binary file not shown.
▼services/__init__.py
+1-0
1
+import services as services
0
2
▼services/__pycache__/pdftoword.cpython-311.pyc
+0-0
Binary file not shown.
▼services/pdftoword.py
+1-0
1
1
from pypdf import PdfReader
2
2
3
+
3
4
async def pdftotext(file):
4
5
with open(file, 'rb') as f:
5
6
reader = PdfReader(f)
6
7