Commit bb50f2c7 by rakesh.pv

made chANGES BASED UPON REVIEW

parent 8523d69c
<?xml version="1.0" encoding="UTF-8"?>
<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>
\ No newline at end of file
......@@ -4,7 +4,7 @@
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="jdk" jdkName="Python 3.11 (mqtt_task)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
......@@ -4,6 +4,6 @@ from scripts.constants.app_configuration import port_no
if __name__ == "__main__":
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:
print("Error-", e)
......@@ -4,9 +4,23 @@ import paho.mqtt.client as mqtt
def send_json():
try:
with open("temp/jsonFile.json", 'r') as filename:
# Load json file
data = json.load(filename)
patient_name = input("enter patient name")
patient_id = int(input("enter patient id"))
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
client = mqtt.Client()
# 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
from fastapi import FastAPI
from scripts.core.handlers.mqtt_publisher import send_json
from scripts.core.routes import routes
# Create object of FastAPI
app = FastAPI()
......@@ -9,10 +10,6 @@ app = FastAPI()
# Setting Root
@app.get("/")
async def root():
return {"INFO": "It's Working!"}
return {"connecetd"}
@app.post("/send_json", tags=["send_json_file"])
async def send_file():
send_json()
return {"STATUS": "SUCCESS"}
app.include_router(routes.router)
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