Commit bb50f2c7 by rakesh.pv

made chANGES BASED UPON REVIEW

parent 8523d69c
<?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
...@@ -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
...@@ -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)
...@@ -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,
"\npatient 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
......
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
# 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"}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment