4thr

swadhinbiswas committed 2 years ago
eb11588
1 parent 6e1b220
commit eb11588
26 files changed
+161 -5
▼__pycache__/main.cpython-311.pyc
+0-0
Binary file not shown.
▼api/v1/handlers/__pycache__/__init__.cpython-311.pyc
+0-0
Binary file not shown.
▼api/v1/handlers/__pycache__/plaguehandel.cpython-311.pyc
+0-0
Binary file not shown.
▼api/v1/handlers/__pycache__/teacherpannel.cpython-311.pyc
+0-0
Binary file not shown.
▼api/v1/handlers/plaguehandel.py
+29-0
1
+from fastapi import APIRouter,Depends,HTTPException
2
+from services import findPlager
3
+from schemas.plagur import OutPlager,PlagerBase,UpdatePlager
4
+from models import plagermodel
5
+from typing import List
6
+import pymongo
7
+
8
+router = APIRouter()
9
+
10
+@router.get("/",response_model=OutPlager)
11
+async def get_plague(data:PlagerBase):
12
+ pass
13
+
14
+@router.get("/all",response_model=List[OutPlager])
15
+async def get_all_plague():
16
+ return await plagermodel.get_plague()
17
+
18
+@router.post("/",response_model=OutPlager)
19
+async def create_plague(data:PlagerBase):
20
+ return await plagermodel.create_plague(data)
21
+
22
+@router.put("/{title}",response_model=OutPlager)
23
+
24
+async def update_plague(title:str,data:UpdatePlager):
25
+ findPlague=await plagermodel.get_plague(title)
26
+ if not findPlague:
27
+ raise HTTPException(status_code=404,detail="Plague not found")
28
+ return await plagermodel.update_plague(title,data)
29
+
0
30
▼main.py
+10-0
1
1
from fastapi import FastAPI
2
+from fastapi.middleware.cors import CORSMiddleware
3
+from fastapi.responses import JSONResponse
4
+from fastapi.encoders import jsonable_encoder
5
+from fastapi.exceptions import RequestValidationError
6
+from api.v1.handlers.teacherpannel import teacher_router
7
+from routes import routersapp
8
+
2
9
3
10
4
11
app = FastAPI(title="Cheacker",
6
13
version="1.0.0",)
7
14
8
15
16
+
17
+
9
18
@app.get("/")
10
19
async def root():
11
20
return {"message": "Hello World"}
12
21
22
+app.include_router(routersapp.app_router,prefix="/apiv1")
13
23
14
24
if __name__ == "__main__":
15
25
import uvicorn
16
26
▼models/TeachersMOdel.py
+1-1
3
3
from typing import Any, Optional
4
4
from datetime import datetime
5
5
from uuid import UUID,uuid4
6
-from beanie import Document, Indexed, DocumentTemplate
6
+from beanie import Document, Indexed
7
7
8
8
class Teacher(Document):
9
9
user_id: UUID = Indexed(default_factory=uuid4)
10
10
▼models/__pycache__/TeachersMOdel.cpython-311.pyc
+0-0
Binary file not shown.
▼models/__pycache__/__init__.cpython-311.pyc
+0-0
Binary file not shown.
▼models/__pycache__/plagermodel.cpython-311.pyc
+0-0
Binary file not shown.
▼models/plagermodel.py
+5-2
1
1
from typing import Any, Optional,List
2
2
from datetime import datetime
3
3
from uuid import UUID,uuid4
4
-from beanie import Document, Indexed, DocumentTemplate
4
+from beanie import Document, Indexed
5
5
6
6
class Plager(Document):
7
7
id: UUID = Indexed(default_factory=uuid4)
8
8
file_name: Optional[str] = None
9
9
title: Optional[str] = None
10
10
owner: List[str] = []
11
- plagarism: Optional[str] = None
11
+ plagarism_persent: Optional[str] = None
12
+ plagur: Optional[bool]=False
13
+
12
14
created_at: Optional[datetime] = datetime.now()
13
15
updated_at: Optional[datetime] = datetime.now()
14
16
description: Optional[str] = None
17
+ word_file_link: Optional[str] = None
15
18
16
19
def __repr__(self):
17
20
return f"<Plagar {self.file_name}>",f"<Plagar {self.title}>",f"<Plagar {self.owner}>",f"<Plagar {self.plagarism}>"
18
21
▼routes/Untitled-1.json
+45-0
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
+}
0
46
▼routes/__pycache__/__init__.cpython-311.pyc
+0-0
Binary file not shown.
▼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
+8-0
1
+from fastapi import APIRouter, HTTPException, status
2
+from api.v1.handlers import plaguehandel,teacherpannel
3
+
4
+app_router=APIRouter()
5
+
6
+app_router.include_router(plaguehandel.router,prefix='/plagures',tags=["plagures"])
7
+app_router.include_router(teacherpannel.teacher_router,prefix='/teachers',tags=["teachers"])
8
+
0
9
▼schemas/__pycache__/plagur.cpython-311.pyc
+0-0
Binary file not shown.
▼schemas/__pycache__/teacher_shema.cpython-311.pyc
+0-0
Binary file not shown.
▼schemas/plagur.py
+11-2
5
5
6
6
class PlagerBase(BaseModel):
7
7
file_name: str=Field(...,description="Name of the file")
8
- title: str=Field(...,description="Title of the file")
8
+ title: str=Field(...,description="Title of the file",max_length=100)
9
9
owner: List[str]=Field(...,description="Owner of the file")
10
10
plagarism: str=Field(...,description="Plagarism of the file")
11
11
description: str=Field(...,description="Description of the file")
12
-
12
+ word_file_link: Optional[str]=Field(...,description="Link to the file")
13
+ plagarism_persent: Optional[str]=Field(...,description="Plagarism persent of the file")
14
+
13
15
class OutPlager(PlagerBase):
14
16
file_name: str
15
17
title: str
16
18
owner: List[str]
17
19
plagarism: str
18
20
description: str
21
+ plagur: bool
22
+ plagarism_persent: str
23
+ word_file_link: str
24
+
25
+
26
+
27
+
19
28
20
29
class UpdatePlager(BaseModel):
21
30
file_name: Optional[str]
22
31
▼services/ServicePlagure.py
+37-0
1
+from typing import Optional, List
2
+from uuid import UUID
3
+from models.plagermodel import Plager
4
+from schemas.plagur import PlagerBase,OutPlager,UpdatePlager
5
+
6
+class PlagerService:
7
+ @staticmethod
8
+ async def create_plager(plager:PlagerBase)->Plager:
9
+ plager_in=Plager(
10
+ file_name=plager.file_name,
11
+ title=plager.title,
12
+ owner=plager.owner,
13
+ description=plager.description,
14
+ word_file_link=plager.word_file_link
15
+
16
+
17
+ )
18
+ await plager_in.save()
19
+ return plager_in
20
+
21
+ @staticmethod
22
+ async def get_plager()->List[Plager]:
23
+ return await Plager.all().to_list()
24
+
25
+ @staticmethod
26
+ async def get_plager_by_title(title:str)->Plager:
27
+ return await Plager.find_one(Plager.title==title)
28
+
29
+ @staticmethod
30
+ async def get_plager_by_owner(owner:str)->Plager:
31
+ return await Plager.find_one(Plager.owner==owner)
32
+
33
+
34
+
35
+
36
+
37
+
0
38
▼services/__pycache__/TeacherService.cpython-311.pyc
+0-0
Binary file not shown.
▼services/__pycache__/__init__.cpython-311.pyc
+0-0
Binary file not shown.
▼services/__pycache__/findPlager.cpython-311.pyc
+0-0
Binary file not shown.
▼services/plagedata.py
+6-0
1
+from services import findPlager
2
+from schemas.plagur import OutPlager,PlagerBase,UpdatePlager
3
+from models import Plague
4
+from typing import List
5
+import pymongo
6
+
0
7
▼services/texttopdf.py
+9-0
1
+from pypdf import PdfReader
2
+
3
+def pdftotext(file):
4
+ with open(file, 'rb') as f:
5
+ reader = PdfReader(f)
6
+ text = ''
7
+ for page in reader.pages:
8
+ text += page.extract_text()
9
+ return text
0
10
▼routes/routers.py → workers/accessdata.py
+0-0
0
0