Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mqtt_v2
Overview
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rakesh.pv
mqtt_v2
Commits
bb50f2c7
Commit
bb50f2c7
authored
Feb 06, 2023
by
rakesh.pv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
made chANGES BASED UPON REVIEW
parent
8523d69c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
42 additions
and
12 deletions
+42
-12
.idea/dbnavigator.xml
+0
-0
.idea/misc.xml
+2
-1
.idea/mqtt_publisher.iml
+2
-1
app.py
+1
-1
scripts/core/handlers/mqtt_publisher.py
+17
-3
scripts/core/routes/routes.py
+17
-0
scripts/services/task_run.py
+3
-6
No files found.
.idea/dbnavigator.xml
0 → 100644
View file @
bb50f2c7
This diff is collapsed.
Click to expand it.
.idea/misc.xml
View file @
bb50f2c7
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<project
version=
"4"
>
<component
name=
"ProjectRootManager"
version=
"2"
project-jdk-name=
"Python 3.
9
(mqtt_task)"
project-jdk-type=
"Python SDK"
/>
<component
name=
"ProjectRootManager"
version=
"2"
project-jdk-name=
"Python 3.
11
(mqtt_task)"
project-jdk-type=
"Python SDK"
/>
</project>
</project>
\ No newline at end of file
.idea/mqtt_publisher.iml
View file @
bb50f2c7
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
<content
url=
"file://$MODULE_DIR$"
>
<content
url=
"file://$MODULE_DIR$"
>
<excludeFolder
url=
"file://$MODULE_DIR$/venv"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/venv"
/>
</content>
</content>
<orderEntry
type=
"
inheritedJdk
"
/>
<orderEntry
type=
"
jdk"
jdkName=
"Python 3.11 (mqtt_task)"
jdkType=
"Python SDK
"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
</component>
</component>
</module>
</module>
\ No newline at end of file
app.py
View file @
bb50f2c7
...
@@ -4,6 +4,6 @@ from scripts.constants.app_configuration import port_no
...
@@ -4,6 +4,6 @@ from scripts.constants.app_configuration import port_no
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
try
:
try
:
uvicorn
.
run
(
"scripts.services.
api_call
:app"
,
port
=
int
(
port_no
),
reload
=
True
)
uvicorn
.
run
(
"scripts.services.
task_run
:app"
,
port
=
int
(
port_no
),
reload
=
True
)
except
Exception
as
e
:
except
Exception
as
e
:
print
(
"Error-"
,
e
)
print
(
"Error-"
,
e
)
scripts/core/handlers/mqtt_publisher.py
View file @
bb50f2c7
...
@@ -4,9 +4,23 @@ import paho.mqtt.client as mqtt
...
@@ -4,9 +4,23 @@ import paho.mqtt.client as mqtt
def
send_json
():
def
send_json
():
try
:
try
:
with
open
(
"temp/jsonFile.json"
,
'r'
)
as
filename
:
patient_name
=
input
(
"enter patient name"
)
# Load json file
patient_id
=
int
(
input
(
"enter patient id"
))
data
=
json
.
load
(
filename
)
patient_description
=
input
(
"enter patient description"
)
patiend_age
=
int
(
input
(
"enter patient age"
))
entire_data
=
{
"patient_description"
:
patient_description
,
"patient_name"
:
patient_name
,
"patient_id"
:
patient_id
,
"age "
:
patiend_age
,
}
print
(
" data that will be published to broker is :
\n\n
"
,
"patiend id :
\n
"
,
patient_id
,
"
\n
patient description
\n\n
"
,
json
.
dumps
(
entire_data
))
data
=
json
.
dumps
(
entire_data
)
# Create MQTT Client
# Create MQTT Client
client
=
mqtt
.
Client
()
client
=
mqtt
.
Client
()
# Create Client connection
# Create Client connection
...
...
scripts/core/routes/routes.py
0 → 100644
View file @
bb50f2c7
from
fastapi
import
APIRouter
from
scripts.core.handlers.mqtt_publisher
import
send_json
router
=
APIRouter
()
# Setting Root
@router.get
(
"/"
)
async
def
root
():
return
{
"connecetd"
}
@router.post
(
"/send_json"
,
tags
=
[
"send_json_file"
])
async
def
send_file
():
send_json
()
return
{
"STATUS"
:
"SUCCESS"
}
\ No newline at end of file
scripts/services/
api_call
.py
→
scripts/services/
task_run
.py
View file @
bb50f2c7
# Importing libraries
# Importing libraries
from
fastapi
import
FastAPI
from
fastapi
import
FastAPI
from
scripts.core.handlers.mqtt_publisher
import
send_json
from
scripts.core.handlers.mqtt_publisher
import
send_json
from
scripts.core.routes
import
routes
# Create object of FastAPI
# Create object of FastAPI
app
=
FastAPI
()
app
=
FastAPI
()
...
@@ -9,10 +10,6 @@ app = FastAPI()
...
@@ -9,10 +10,6 @@ app = FastAPI()
# Setting Root
# Setting Root
@app.get
(
"/"
)
@app.get
(
"/"
)
async
def
root
():
async
def
root
():
return
{
"
INFO"
:
"It's Working!
"
}
return
{
"
connecetd
"
}
app
.
include_router
(
routes
.
router
)
@app.post
(
"/send_json"
,
tags
=
[
"send_json_file"
])
async
def
send_file
():
send_json
()
return
{
"STATUS"
:
"SUCCESS"
}
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