Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-073
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2022-073
2022-073
Commits
9668a607
Commit
9668a607
authored
Oct 09, 2022
by
Nilan Meegoda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CORS issue fix
parent
e90edc3c
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
194 additions
and
153 deletions
+194
-153
web-app/backend/db.py
web-app/backend/db.py
+1
-1
web-app/backend/server.py
web-app/backend/server.py
+27
-9
web-app/frontend/src/components/activities/ethicalClearence.jsx
...p/frontend/src/components/activities/ethicalClearence.jsx
+112
-73
web-app/frontend/src/pages/student/Student.jsx
web-app/frontend/src/pages/student/Student.jsx
+15
-18
web-app/frontend/src/pages/student/student_reg.css
web-app/frontend/src/pages/student/student_reg.css
+23
-39
web-app/frontend/src/pages/student/student_reg.jsx
web-app/frontend/src/pages/student/student_reg.jsx
+16
-13
No files found.
web-app/backend/db.py
View file @
9668a607
import
urllib.parse
from
flask
import
Flask
from
flask_pymongo
import
pymongo
from
app
import
app
from
server
import
app
...
...
web-app/backend/server.py
View file @
9668a607
...
...
@@ -2,11 +2,15 @@
import
os
from
flask
import
Flask
,
flash
,
request
,
redirect
,
url_for
,
session
,
jsonify
from
werkzeug.utils
import
secure_filename
import
flask_cors
from
flask_cors
import
CORS
,
cross_origin
from
pymongo
import
MongoClient
from
bson.objectid
import
ObjectId
from
PIL
import
Image
import
datetime
import
yaml
import
base64
import
io
# Libraries required for model utilization
import
cv2
as
cv
...
...
@@ -52,12 +56,26 @@ def predictAttention():
return
scoreLst
@
app
.
route
(
'/candidateReg'
,
methods
=
[
'GET'
])
def
registerCandidate
():
print
(
"API working"
)
response
=
"API working"
return
response
@
app
.
route
(
'/parents/'
,
methods
=
[
'POST'
,
'GET'
])
@
cross_origin
()
def
data2
():
print
(
"Request type:"
+
request
.
method
)
# POST a data to database
if
request
.
method
==
'POST'
:
body
=
request
.
json
parentName
=
body
[
'parentName'
]
parentSignature
=
body
[
'parentSignature'
]
ChildCandidate
=
body
[
'ChildCandidate'
]
# db.users.insert_one({
db
.
db
[
'parents'
]
.
insert_one
({
"parentName"
:
parentName
,
"parentSignature"
:
parentSignature
,
"ChildCandidate"
:
ChildCandidate
,
})
return
jsonify
({
'status'
:
'Parents details are added to the system successfully!'
,
})
@
app
.
route
(
'/users/'
,
methods
=
[
'POST'
,
'GET'
])
@
cross_origin
()
...
...
@@ -177,10 +195,10 @@ def onedata(id):
print
(
'
\n
# Update successful #
\n
'
)
return
jsonify
({
'status'
:
'Data id: '
+
id
+
' is updated!'
})
@
app
.
route
(
"/testDB"
)
def
test
():
db
.
db
.
collection
.
insert_one
({
"name"
:
"John"
})
return
"Connected to the data base!"
#
@app.route("/testDB")
#
def test():
#
db.db.collection.insert_one({"name": "John"})
#
return "Connected to the data base!"
# Running app
if
__name__
==
"__main__"
:
...
...
web-app/frontend/src/components/activities/ethicalClearence.jsx
View file @
9668a607
This diff is collapsed.
Click to expand it.
web-app/frontend/src/pages/student/Student.jsx
View file @
9668a607
import
React
,
{
useState
,
useEffect
}
from
"
react
"
;
import
"
./Student.css
"
;
import
{
ActivityContainer
,
ContainerCard
}
from
"
../../components/index
"
;
import
{
ContainerCard
}
from
"
../../components/index
"
;
import
{
useNavigate
}
from
"
react-router-dom
"
;
import
{
Fragment
}
from
"
react
"
;
import
{
Popover
,
Transition
}
from
"
@headlessui/react
"
;
...
...
@@ -9,28 +9,18 @@ import logo from "../../assets/logo1.png";
import
sl_kids
from
"
../../assets/image.png
"
;
const
Student
=
()
=>
{
const
navigate
=
useNavigate
();
const
navigation
=
[
{
name
:
"
Introduction
"
,
href
:
"
/
"
},
{
name
:
"
Features
"
,
href
:
"
/features
"
},
];
const
navigate
=
useNavigate
();
const
buttonHandler
=
()
=>
{
setGetStarttedstate
((
current
)
=>
!
current
);
};
const
goTo
=
(
path
)
=>
{
navigate
(
path
);
};
const
[
isGetStarttedClicked
,
setGetStarttedstate
]
=
useState
(
false
);
const
[
isFeaturesRequested
,
setFeaturesRequestedstate
]
=
useState
(
false
);
useEffect
(()
=>
{},
[
isGetStarttedClicked
]);
return
(
<>
<
div
className=
"student-page-angry-grid"
>
<
div
id=
"student-page-item-0"
>
<
ContainerCard
>
{
!
isGetStarttedClicked
&&
!
isFeaturesRequested
&&
(
{
<>
<
div
className=
"welcome_screen-page-angry-grid p-4 m-9"
>
<
div
className=
"relative bg-white overflow-hidden rounded-md"
>
...
...
@@ -81,7 +71,7 @@ const Student = () => {
key=
{
item
.
name
}
href=
"#"
className=
"font-medium text-gray-500 hover:text-[#3d59c1]"
onClick=
{
goTo
(
item
.
href
)
}
onClick=
{
()
=>
navigate
(
item
.
href
)
}
>
{
item
.
name
}
</
a
>
...
...
@@ -130,7 +120,7 @@ const Student = () => {
key=
{
item
.
name
}
href=
"#"
className=
"block px-3 py-2 rounded-md text-base font-medium text-gray-700 hover:text-gray-900 hover:bg-gray-50"
onClick=
{
goTo
(
item
.
href
)
}
onClick=
{
()
=>
navigate
(
item
.
href
)
}
>
{
item
.
name
}
</
a
>
...
...
@@ -167,9 +157,16 @@ const Student = () => {
<
div
className=
"mt-5 sm:mt-8 sm:flex sm:justify-center lg:justify-start"
>
<
div
className=
"rounded-md shadow"
>
<
a
href=
"#"
className=
"w-full flex items-center justify-center px-8 py-3 border border-transparent text-base font-medium rounded-md text-white bg-[#3d59c1] hover:bg-indigo-700 md:py-4 md:text-lg md:px-10"
onClick=
{
goTo
(
"
/ethicalScreen
"
)
}
onClick=
{
()
=>
navigate
(
"
/stdReg
"
)
}
>
Regsiter a new candidate
</
a
>
</
div
>
<
div
className=
"rounded-md shadow ml-3"
>
<
a
className=
"w-full flex items-center justify-center px-8 py-3 border border-transparent text-base font-medium rounded-md text-white bg-[#3d59c1] hover:bg-indigo-700 md:py-4 md:text-lg md:px-10"
onClick=
{
()
=>
navigate
(
"
/ethicalScreen
"
)
}
>
Get started
</
a
>
...
...
@@ -189,7 +186,7 @@ const Student = () => {
</
div
>
</
div
>
</>
)
}
}
</
ContainerCard
>
</
div
>
</
div
>
...
...
web-app/frontend/src/pages/student/student_reg.css
View file @
9668a607
.stdReg_screen-page-angry-grid
{
margin
:
6%
;
margin-top
:
2%
;
margin-bottom
:
3%
;
}
.stdReg_screen-page-header-options
:hover
{
color
:
teal
;
}
#stdReg_screen-page-item-0
{
grid-row-start
:
1
;
grid-column-start
:
1
;
grid-row-end
:
2
;
grid-column-end
:
6
;
display
:
flex
;
justify-content
:
space-between
;
padding-left
:
5vw
;
padding-right
:
5vw
;
padding-top
:
5vh
;
font-family
:
var
(
--font-family
);
font-weight
:
500
;
font-size
:
2em
;
color
:
white
;
}
#stdReg_screen-page-item-2
{
grid-row-start
:
2
;
grid-column-start
:
2
;
.activity-container-angry-grid
{
display
:
grid
;
grid-row-end
:
4
;
grid-column-end
:
4
;
grid-template-rows
:
1
fr
1
fr
1
fr
;
grid-template-columns
:
1
fr
1
fr
1
fr
1
fr
1
fr
;
height
:
80vh
;
width
:
120ch
;
}
\ No newline at end of file
gap
:
0px
;
height
:
100%
;
padding
:
20px
;
}
#activity-container-item-0
{
grid-row-start
:
1
;
grid-column-start
:
1
;
grid-row-end
:
4
;
grid-column-end
:
2
;
margin-right
:
10px
;
border
:
solid
gainsboro
;
border-radius
:
5px
;
padding
:
5px
;
}
\ No newline at end of file
web-app/frontend/src/pages/student/student_reg.jsx
View file @
9668a607
import
React
,
{
useState
}
from
"
react
"
;
import
axios
from
"
axios
"
;
import
{
ContainerCard
}
from
"
../../components/index
"
;
import
toast
,
{
Toaster
}
from
"
react-hot-toast
"
;
import
"
./student_reg.css
"
;
//
import { useNavigate } from "react-router-dom";
import
{
useNavigate
}
from
"
react-router-dom
"
;
import
API
from
"
../../config/api
"
;
const
StdReg_screen
=
()
=>
{
const
navigate
=
useNavigate
();
const
[
firstName
,
setFirstName
]
=
useState
(
""
);
const
[
lastName
,
setLastName
]
=
useState
(
""
);
const
[
nationality
,
setNationality
]
=
useState
(
""
);
...
...
@@ -63,10 +64,11 @@ const StdReg_screen = () => {
<
div
>
<
Toaster
/>
</
div
>
<
div
className=
"stdReg_screen-page-angry-grid px-12"
>
<
div
className=
"relative bg-white mt-6 rounded-md py-5 px-5"
>
<
div
className=
"mt-10 sm:mt-0"
>
<
div
className=
"md:grid md:grid-cols-3 md:gap-6"
>
<
div
className=
"stdReg_screen-page-angry-grid"
>
<
div
id=
"student-page-item-0"
>
<
ContainerCard
>
<
div
className=
"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"
>
<
div
className=
"md:grid md:grid-cols-3 md:gap-6"
>
<
div
className=
"md:col-span-1"
>
<
div
className=
"px-4 sm:px-0"
>
<
h3
className=
"text-lg font-medium leading-6 text-gray-900"
>
...
...
@@ -218,8 +220,14 @@ const StdReg_screen = () => {
</
div
>
<
div
className=
"px-4 py-3 bg-gray-50 text-right sm:px-6"
>
<
button
type=
"submit"
onClick=
{
()
=>
navigate
(
"
/
"
)
}
className=
"inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-[#3d59c1] hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
>
Get back
</
button
>
<
button
type=
"submit"
className=
"inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-[#3d59c1] hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 ml-3"
>
Add Candidate
</
button
>
...
...
@@ -229,12 +237,7 @@ const StdReg_screen = () => {
</
div
>
</
div
>
</
div
>
<
div
className=
"hidden sm:block"
aria
-
hidden=
"true"
>
<
div
className=
"py-5"
>
<
div
className=
"border-t border-gray-200"
/>
</
div
>
</
div
>
</
ContainerCard
>
</
div
>
</
div
>
</>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment