{"id":20169161,"url":"https://github.com/shikha-code36/flask-rediscaching-in-docker","last_synced_at":"2026-04-07T22:31:09.169Z","repository":{"id":114296629,"uuid":"517037012","full_name":"Shikha-code36/Flask-RedisCaching-in-Docker","owner":"Shikha-code36","description":"Flask Api with Redis caching in docker","archived":false,"fork":false,"pushed_at":"2023-03-18T17:52:31.000Z","size":157,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-03T04:13:15.320Z","etag":null,"topics":["docker","docker-compose","docker-container","docker-image","dockerfile","flask","flask-api","flask-caching","flask-restful","flask-sqlalchemy","python","python3","redis","redis-cache","rest-api"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Shikha-code36.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-23T11:19:48.000Z","updated_at":"2024-03-28T18:14:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"47c828f7-a295-4000-ab15-fc1de7093571","html_url":"https://github.com/Shikha-code36/Flask-RedisCaching-in-Docker","commit_stats":null,"previous_names":["shikha-code36/flask-rediscaching-in-docker"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shikha-code36%2FFlask-RedisCaching-in-Docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shikha-code36%2FFlask-RedisCaching-in-Docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shikha-code36%2FFlask-RedisCaching-in-Docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shikha-code36%2FFlask-RedisCaching-in-Docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Shikha-code36","download_url":"https://codeload.github.com/Shikha-code36/Flask-RedisCaching-in-Docker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241605819,"owners_count":19989612,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-compose","docker-container","docker-image","dockerfile","flask","flask-api","flask-caching","flask-restful","flask-sqlalchemy","python","python3","redis","redis-cache","rest-api"],"created_at":"2024-11-14T01:11:36.486Z","updated_at":"2025-11-29T03:09:07.718Z","avatar_url":"https://github.com/Shikha-code36.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flask API with Redis Caching in Docker\n\nThis is a simple Flask API project that uses Redis caching and can be run in a Docker container. The API has the following endpoints:\n\n- `/getdata/\u003cdevice_fk_id\u003e`: Returns the latest information for a given device ID, including device_fk_id, latitude, longitude, time_stamp, sts, and speed.\n- `/getlocation/\u003cdevice_fk_id\u003e`: Returns the start location and end location for a given device ID as a tuple of (latitude, longitude).\n- `/getinfo`: Takes in device ID, start time, and end time and returns all the location points as a list of latitude, longitude, and time stamp.\n\n\n## Usage\n\n1. Clone the repository: `git clone https://github.com/\u003cusername\u003e/Flask-RedisCaching-in-Docker.git`\n2. Navigate to the project directory in your terminal.\n3. Build the Docker image: `docker build -t flask-api-with-caching`.\n4. Start the Docker containers: `docker-compose`.\n5. Access the API endpoints at `http://127.0.0.1:5000/`\n\n- **Note** Replace `\u003cusername\u003e` with your GitHub username in step 1.\n\n### Endpoints\n\n#### /allData\n\nReturns the latest information for all device ID, including device_fk_id, latitude, longitude, time_stamp, sts, and speed.\n\n**Request URL:** `http://127.0.0.1:5000/alldata`\n\n**Request Method:** GET\n\n**URL Params:**\n\n- None\n\n**Response:**\n\n```\n[{\n\"device_fk_id\": \"\u003cdevice_fk_id\u003e\",\n\"latitude\": \"\u003clatitude\u003e\",\n\"longitude\": \"\u003clongitude\u003e\",\n\"time_stamp\": \"\u003ctime_stamp\u003e\",\n\"sts\": \"\u003csts\u003e\",\n\"speed\": \"\u003cspeed\u003e\"\n},\n{\n\"device_fk_id\": \"\u003cdevice_fk_id\u003e\",\n\"latitude\": \"\u003clatitude\u003e\",\n\"longitude\": \"\u003clongitude\u003e\",\n\"time_stamp\": \"\u003ctime_stamp\u003e\",\n\"sts\": \"\u003csts\u003e\",\n\"speed\": \"\u003cspeed\u003e\"\n}\n...\n]\n```\n\n\n#### /getdata/\u003cdevice_fk_id\u003e\n\nReturns the latest information for a given device ID, including device_fk_id, latitude, longitude, time_stamp, sts, and speed.\n\n**Request URL:** `http://127.0.0.1:5000/getdata/\u003cdevice_fk_id\u003e`\n\n**Request Method:** GET\n\n**URL Params:**\n\n- `device_fk_id` (required): The device ID for which you want to retrieve information.\n\n**Response:**\n\n```\n{\n\"device_fk_id\": \"\u003cdevice_fk_id\u003e\",\n\"latitude\": \"\u003clatitude\u003e\",\n\"longitude\": \"\u003clongitude\u003e\",\n\"time_stamp\": \"\u003ctime_stamp\u003e\",\n\"sts\": \"\u003csts\u003e\",\n\"speed\": \"\u003cspeed\u003e\"\n}\n```\n\n\n#### /getlocation/\u003cdevice_fk_id\u003e\n\nReturns the start location and end location for a given device ID as a tuple of (latitude, longitude).\n\n**Request URL:** `http://127.0.0.1:5000/getlocation/\u003cdevice_fk_id\u003e`\n\n**Request Method:** GET\n\n**URL Params:**\n\n- `device_fk_id` (required): The device ID for which you want to retrieve location information.\n\n**Response:**\n\n```\n{\n\"start_location\": [\n\"\u003clatitude\u003e\",\n\"\u003clongitude\u003e\"\n],\n\"end_location\": [\n\"\u003clatitude\u003e\",\n\"\u003clongitude\u003e\"\n]\n}\n```\n\n#### /getinfo\n\nTakes in device ID, start time, and end time and returns all the location points as a list of latitude, longitude, and time stamp.\n\n**Request URL:** `http://127.0.0.1:5000/getinfo`\n\n**Request Method:** GET\n\n**URL Params:**\n\n- `deviceId` (required): The device ID for which you want to retrieve location information.\n- `starttime` (optional): The start time for the location points (format: %Y-%m-%dT%H:%M:%SZ).\n- `endtime` (optional): The end time for the location points (format: %Y-%m-%dT%H:%M:%SZ).\n\n**Response:**\n\n```\n[\n{\n\"latitude\": \"\u003clatitude\u003e\",\n\"longitude\": \"\u003clongitude\u003e\",\n\"time_stamp\": \"\u003ctime_stamp\u003e\"\n},\n{\n\"latitude\": \"\u003clatitude\u003e\",\n\"longitude\": \"\u003clongitude\u003e\",\n\"time_stamp\": \"\u003ctime_stamp\u003e\"\n},\n...\n]\n```\n\n\n## Dependencies\n\n- Flask\n- Flask-Caching\n- Redis\n- SQLAlchemy\n\n## Files\n\n```\nFlask-RedisCaching-in-Docker\n├── app/\n│ ├── init.py\n│ ├── getData.py\n│ ├── getInfo.py\n│ ├── location.py\n│ └── allData.py\n├── utils/\n│ └── raw_data.csv\n├── .gitignore\n├── data.py\n├── constant.py\n├── Dockerfile\n├── docker-compose.yml\n└── model.py\n```\n\n- `app/`: Contains the Flask application code.\n    - `__init__.py`: Initializes the Flask app and registers the routes.\n    - `getData.py`: Contains the code for the `/getdata/\u003cdevice_fk_id\u003e` endpoint.\n    - `getInfo.py`: Contains the code for the `/getinfo` endpoint.\n    - `location.py`: Contains the code for the `/getlocation/\u003cdevice_fk_id\u003e` endpoint.\n    - `allData.py`: Contains the code for the `/alldata` endpoint.\n- `utils/`: Contains the raw data in `raw_data.csv` file.\n- `.gitignore`: Specifies files that should be ignored by Git.\n- `data.py`: Contains functions for retrieving data.\n- `constant.py`: Contains constant values used throughout the application.\n- `Dockerfile`: Contains instructions for building the Docker image.\n- `docker-compose.yml`: Contains instructions for running the Docker container.\n- `model.py`: Contains the data model for the application.\n\n## Caching\n\nThe application uses Redis as the caching layer, with a caching timeout of 120 seconds.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshikha-code36%2Fflask-rediscaching-in-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshikha-code36%2Fflask-rediscaching-in-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshikha-code36%2Fflask-rediscaching-in-docker/lists"}