Commit b2ebebca by mohammed.shibili

wild card

parent 2b9b9fe7
...@@ -8,3 +8,7 @@ redis_db=hospital ...@@ -8,3 +8,7 @@ redis_db=hospital
mqtt_broker=192.168.0.220 mqtt_broker=192.168.0.220
mqtt_port=1883 mqtt_port=1883
mqtt_time=60 mqtt_time=60
[end_points]
get=/doctors
post=/patients
\ No newline at end of file
import configparser
config = configparser.RawConfigParser()
config.read("conf/app.conf")
get_end = config.get("end_point", "get")
post_end = config.get("end_point", "post")
\ No newline at end of file
...@@ -5,4 +5,4 @@ class patient_details(BaseModel): ...@@ -5,4 +5,4 @@ class patient_details(BaseModel):
patient_id: str patient_id: str
name: str name: str
age: int age: int
description: str description: str
\ No newline at end of file
import json import json
from fastapi import FastAPI from fastapi import FastAPI
from script.config.end_points import get_end, post_end
from script.core.handlers.mqtt_coo import mqtt_conn from script.core.handlers.mqtt_coo import mqtt_conn
from script.core.handlers.redis_connection import redis_connection from script.core.handlers.redis_connection import redis_connection
from script.database.models import patient_details from script.database.models import patient_details
...@@ -14,15 +16,15 @@ patient_info = {} ...@@ -14,15 +16,15 @@ patient_info = {}
# api call for generating doctors list # api call for generating doctors list
@app.get("/doctors", tags=['REDIS']) @app.get(get_end, tags=['REDIS'])
async def doctor(no_of_doctors: int): async def doctor(no_of_doctors: int):
for doctors in range(1, no_of_doctors + 1): for doctors in range(1, no_of_doctors + 1):
doctors_list.append(f'doctor{doctors}') doctors_list.append(f'/doctor{doctors}')
# publishing doctors list to redis # publishing doctors list to redis
connection_redis.lpush("available_doctors", f'doctor{doctors}') connection_redis.lpush("available_doctors", f'doctor{doctors}')
@app.post("/patients", tags=["REDIS"]) @app.post(post_end, tags=["REDIS"])
async def patients(body: patient_details): async def patients(body: patient_details):
global topic global topic
global current_doctor global current_doctor
......
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