Commit 3b4e6a18 by arun.uday

v2

parent 151e1270
......@@ -4,7 +4,14 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="530f9a40-4e97-41f4-9693-adc3b4faba7d" name="Changes" comment="" />
<list default="true" id="530f9a40-4e97-41f4-9693-adc3b4faba7d" name="Changes" comment="v1">
<change afterPath="$PROJECT_DIR$/scripts/config/api_route_config.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app.py" beforeDir="false" afterPath="$PROJECT_DIR$/app.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/conf/application.conf" beforeDir="false" afterPath="$PROJECT_DIR$/conf/application.conf" afterDir="false" />
<change beforePath="$PROJECT_DIR$/scripts/config/applications_config.py" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/config/applications_config.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/scripts/services/receiver_app_run.py" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/services/receiver_app_run.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
......@@ -29,14 +36,15 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;last_opened_file_path&quot;: &quot;E:/KL projects/task9receiverredis&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;project.propVCSSupport.DirectoryMappings&quot;
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"SONARLINT_PRECOMMIT_ANALYSIS": "true",
"last_opened_file_path": "E:/KL projects/task9senderredis",
"settings.editor.selected.configurable": "project.propVCSSupport.DirectoryMappings"
}
}</component>
}]]></component>
<component name="RunManager">
<configuration name="app" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
<module name="redis receiver" />
......@@ -70,6 +78,18 @@
<option name="presentableId" value="Default" />
<updated>1675224688329</updated>
</task>
<task id="LOCAL-00001" summary="v1">
<created>1675310885575</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1675310885575</updated>
</task>
<option name="localTasksCounter" value="2" />
<servers />
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="v1" />
<option name="LAST_COMMIT_MESSAGE" value="v1" />
</component>
</project>
\ No newline at end of file
import uvicorn
from scripts.config.applications_config import uvicorn_host, uvicorn_port
from scripts.config.applications_config import uvicorn_host, uvicorn_port, uvicorn_app
# starting the application
if __name__ == "__main__":
print("redis MQTT task")
uvicorn.run("scripts.services.receiver_app_run:app", host=uvicorn_host, port=int(uvicorn_port))
uvicorn.run(uvicorn_app, host=uvicorn_host, port=int(uvicorn_port))
......@@ -12,6 +12,7 @@ requests = 60
[uvicorn]
uvicorn_host = 127.0.0.1
uvicorn_port = 8001
uvicorn_app = scripts.services.receiver_app_run:app
# database servers
[connection]
......@@ -19,3 +20,10 @@ mongodb = mongodb://localhost:27017
[redis_db]
redis_host = 127.0.0.1
[encode]
encode = utf-8
[api_routes]
index_route = /
import configparser
config = configparser.RawConfigParser()
config.read("conf/application.conf")
# api routes
index_route = config.get("api_route", 'index_route')
......@@ -23,6 +23,10 @@ client_connect = config.get("connection", "mongodb")
# uvicorn
uvicorn_host = config.get("uvicorn", "uvicorn_host")
uvicorn_port = config.get("uvicorn", "uvicorn_port")
uvicorn_app = config.get("uvicorn", "uvicorn_app")
# redis
redis_host = config.get("redis_db", "redis_host")
# encode
utf_encode = config.get("encode", "encode")
import paho.mqtt.client as mqtt
from fastapi import FastAPI
from scripts.config.applications_config import mqtt_host, port, request_no
from scripts.config.api_route_config import index_route
from scripts.config.applications_config import mqtt_host, port, request_no, utf_encode
from scripts.core.engine.redis_db import conn
from scripts.core.handlers.reading_doctors import read_doctors
......@@ -11,7 +12,7 @@ app = FastAPI()
# subscribing to the doctor topics and getting the messages
@app.get("/")
@app.get(index_route)
def receiver():
# subscribe to the doctor topics
def on_connect(client_name, userdata, flags, rc):
......@@ -23,7 +24,7 @@ def receiver():
def on_message(client_name, userdata, msg):
print(client_name, " ", userdata)
# decoding the msg to string
payload_decoded = msg.payload.decode('utf-8')
payload_decoded = msg.payload.decode(utf_encode)
print(msg.topic, "assigned to", payload_decoded)
# creating the paho client for mqtt
......
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