Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
python-sample
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
BCP
python-sample
Commits
c85307bc
Commit
c85307bc
authored
Jan 07, 2021
by
ksankar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added python file
parents
Pipeline
#1837
failed with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
+31
-0
restpy.py
restpy.py
+31
-0
No files found.
restpy.py
0 → 100644
View file @
c85307bc
from
flask
import
Flask
,
request
from
flask_restful
import
Resource
,
Api
from
json
import
dumps
app
=
Flask
(
__name__
)
api
=
Api
(
app
)
class
Employees
(
Resource
):
def
get
(
self
):
return
{
'employees'
:
[
'kk'
,
'ss'
,
'dd'
]}
# Fetches first column that is Employee ID
class
Tracks
(
Resource
):
def
get
(
self
):
result
=
{
'data'
:
[
'track1'
,
'track2'
,
'track3'
]}
return
result
class
Employees_Name
(
Resource
):
def
get
(
self
,
employee_id
):
result
=
{
'data'
:
[
'Karthick'
]}
return
result
api
.
add_resource
(
Employees
,
'/employees'
)
# Route_1
api
.
add_resource
(
Tracks
,
'/tracks'
)
# Route_2
api
.
add_resource
(
Employees_Name
,
'/employees/<employee_id>'
)
# Route_3
if
__name__
==
'__main__'
:
app
.
run
(
port
=
'5002'
)
\ No newline at end of file
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