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
9789de22
Commit
9789de22
authored
Jan 12, 2021
by
sathish
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update restpy.py
parent
c85307bc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
31 deletions
+22
-31
restpy.py
restpy.py
+22
-31
No files found.
restpy.py
View file @
9789de22
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
import
socket
;
from
datetime
import
date
;
# Function to display hostname and
# IP address
def
get_Host_name_IP
():
try
:
host_name
=
socket
.
gethostname
()
host_ip
=
socket
.
gethostbyname
(
host_name
)
today
=
date
.
today
()
d2
=
today
.
strftime
(
"
%
B
%
d,
%
Y"
)
print
(
"###################################"
)
print
(
"Date : "
,
d2
)
print
(
"Hostname : "
,
host_name
)
print
(
"IP : "
,
host_ip
)
print
(
"###################################"
)
except
:
print
(
"Unable to get Hostname and IP"
)
# Driver code
get_Host_name_IP
()
\ 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