Commit 3b4e6a18 by arun.uday

v2

parent 151e1270
...@@ -4,7 +4,14 @@ ...@@ -4,7 +4,14 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <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="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
...@@ -29,14 +36,15 @@ ...@@ -29,14 +36,15 @@
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent">{ <component name="PropertiesComponent"><![CDATA[{
&quot;keyToString&quot;: { "keyToString": {
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;, "RunOnceActivity.OpenProjectViewOnStart": "true",
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;, "RunOnceActivity.ShowReadmeOnStart": "true",
&quot;last_opened_file_path&quot;: &quot;E:/KL projects/task9receiverredis&quot;, "SONARLINT_PRECOMMIT_ANALYSIS": "true",
&quot;settings.editor.selected.configurable&quot;: &quot;project.propVCSSupport.DirectoryMappings&quot; "last_opened_file_path": "E:/KL projects/task9senderredis",
"settings.editor.selected.configurable": "project.propVCSSupport.DirectoryMappings"
} }
}</component> }]]></component>
<component name="RunManager"> <component name="RunManager">
<configuration name="app" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true"> <configuration name="app" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
<module name="redis receiver" /> <module name="redis receiver" />
...@@ -70,6 +78,18 @@ ...@@ -70,6 +78,18 @@
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1675224688329</updated> <updated>1675224688329</updated>
</task> </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 /> <servers />
</component> </component>
<component name="VcsManagerConfiguration">
<MESSAGE value="v1" />
<option name="LAST_COMMIT_MESSAGE" value="v1" />
</component>
</project> </project>
\ No newline at end of file
import uvicorn 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 # starting the application
if __name__ == "__main__": if __name__ == "__main__":
print("redis MQTT task") 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 ...@@ -12,6 +12,7 @@ requests = 60
[uvicorn] [uvicorn]
uvicorn_host = 127.0.0.1 uvicorn_host = 127.0.0.1
uvicorn_port = 8001 uvicorn_port = 8001
uvicorn_app = scripts.services.receiver_app_run:app
# database servers # database servers
[connection] [connection]
...@@ -19,3 +20,10 @@ mongodb = mongodb://localhost:27017 ...@@ -19,3 +20,10 @@ mongodb = mongodb://localhost:27017
[redis_db] [redis_db]
redis_host = 127.0.0.1 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") ...@@ -23,6 +23,10 @@ client_connect = config.get("connection", "mongodb")
# uvicorn # uvicorn
uvicorn_host = config.get("uvicorn", "uvicorn_host") uvicorn_host = config.get("uvicorn", "uvicorn_host")
uvicorn_port = config.get("uvicorn", "uvicorn_port") uvicorn_port = config.get("uvicorn", "uvicorn_port")
uvicorn_app = config.get("uvicorn", "uvicorn_app")
# redis # redis
redis_host = config.get("redis_db", "redis_host") redis_host = config.get("redis_db", "redis_host")
# encode
utf_encode = config.get("encode", "encode")
import paho.mqtt.client as mqtt import paho.mqtt.client as mqtt
from fastapi import FastAPI 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.engine.redis_db import conn
from scripts.core.handlers.reading_doctors import read_doctors from scripts.core.handlers.reading_doctors import read_doctors
...@@ -11,7 +12,7 @@ app = FastAPI() ...@@ -11,7 +12,7 @@ app = FastAPI()
# subscribing to the doctor topics and getting the messages # subscribing to the doctor topics and getting the messages
@app.get("/") @app.get(index_route)
def receiver(): def receiver():
# subscribe to the doctor topics # subscribe to the doctor topics
def on_connect(client_name, userdata, flags, rc): def on_connect(client_name, userdata, flags, rc):
...@@ -23,7 +24,7 @@ def receiver(): ...@@ -23,7 +24,7 @@ def receiver():
def on_message(client_name, userdata, msg): def on_message(client_name, userdata, msg):
print(client_name, " ", userdata) print(client_name, " ", userdata)
# decoding the msg to string # 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) print(msg.topic, "assigned to", payload_decoded)
# creating the paho client for mqtt # 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