{"id":22955280,"url":"https://github.com/happycod3r/js-loves-py","last_synced_at":"2026-05-03T16:31:36.375Z","repository":{"id":187574217,"uuid":"677165085","full_name":"happycod3r/JS-Loves-Py","owner":"happycod3r","description":"JS ❤️ Py is a set of scripts used to easily pass data back and forth between Python \u0026 JavaScript","archived":false,"fork":false,"pushed_at":"2023-08-13T18:30:03.000Z","size":1970,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T00:42:08.321Z","etag":null,"topics":["bridge","data-transfer","file-detection","javascript","javascript-python","js","json","json-data","py","python","python-3","python-javascript","python3"],"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/happycod3r.png","metadata":{"files":{"readme":"docs/README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2023-08-10T22:49:09.000Z","updated_at":"2024-12-09T10:17:59.000Z","dependencies_parsed_at":"2024-12-14T16:38:58.831Z","dependency_job_id":null,"html_url":"https://github.com/happycod3r/JS-Loves-Py","commit_stats":null,"previous_names":["happycod3r/js-loves-py"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/happycod3r/JS-Loves-Py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/happycod3r%2FJS-Loves-Py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/happycod3r%2FJS-Loves-Py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/happycod3r%2FJS-Loves-Py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/happycod3r%2FJS-Loves-Py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/happycod3r","download_url":"https://codeload.github.com/happycod3r/JS-Loves-Py/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/happycod3r%2FJS-Loves-Py/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32577119,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T06:36:36.687Z","status":"ssl_error","status_checked_at":"2026-05-03T06:36:09.306Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["bridge","data-transfer","file-detection","javascript","javascript-python","js","json","json-data","py","python","python-3","python-javascript","python3"],"created_at":"2024-12-14T16:28:53.923Z","updated_at":"2026-05-03T16:31:36.341Z","avatar_url":"https://github.com/happycod3r.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JS ❤️ PY\r\n\r\n## JavaScript and Python Coupling\r\n\r\n\u003e JS Loves Py is a set of scripts that will allow you to easily pass data back and forth between JavaScript and Python using Json. I created this project to highlight this ability. It demonstrates one of many ways you can couple langauges together to work with one another. The ability to pass data back and forth between two languages like Python and JavaScript opens doors to a universe of new possibilities.\r\n\r\n## [Table Of Contents](#table-of-contents)\r\n\r\n- [Table of Contents](#table-of-contents)\r\n- [About](#about)\r\n- [Usage](#usage)\r\n  - [JS Class Methods](#js-class-methods)\r\n  - [Py Class Methods](#py-class-methods)\r\n  - [Examples](#examples)\r\n    - [JS ➟ Py](#js2py)\r\n    - [Py ➟ JS](#py2js)\r\n- [Python \u0026 JavaScript Use Cases](#use-cases)\r\n  - [Web Development](#web-development)\r\n  - [Data Visualization](#data-visualization)\r\n  - [Full-Stack Applications](#full-stack-applications)\r\n  - [Machine Learning and AI](#machine-learning-and-ai)\r\n  - [Cross-Platform Desktop Applications](#desktop-applications)\r\n  - [Embedded Widgets \u0026 Widgets in Content Management Systems](#content-management-systems)\r\n- [Benefits of Using JavaScript with Python](#benefits)\r\n  - [Leveraging Strengths](#leveraging-strengths)\r\n  - [Ecosystem Diversity](#ecosystem-diversity)\r\n  - [Flexibility](#flexibility)\r\n  - [Separation of Concerns](#seperation-of-concerns)\r\n  - [Scalability](#scalability)\r\n- [Contributing](#contributing)\r\n- [Security](#security)\r\n- [Contacts](#contacts)\r\n---\r\n\r\n# [About](#about)\r\nJS loves Py contains two classes. One in JavaScript called `JS()` and the other in Python call `Py()`. These two classes are identical other than the fact that one is written in Python and the other in JavaScript. Both classes allow you to pass an object back and forth between Python and JavaScript easily using Json. Each class creates a Json file which it will store the data being passed in. The Json files created by both classes are called `from_js.json` and `from_py.json` respectively.\r\n\r\nSince Json, a JavaScript object and a Python dictionary all have the same syntax this can be leveraged to easily pass objects back and forth between Python and JavaScript (*or really any language that can work with Json and/or has a similar object like structure {}*). On top of that you can create listeners to automate getting the data being passed as I have here with the `JS.checkForNote()` and `Py.check_for_note()` methods.\r\nAll you have to do is specify the path to the place where the ***from_js.json*** and ***from_py.json*** files will be created by passing it to whichever listener is being used or both.\r\n\r\n\u003e Heres an example of the listeners in both scripts in action. In this example I drag and drop the data files into the directory being listened to for the sake of time. You can see though that as I drop each file into the folder the output displays the contents.\r\n\r\n![Example Usage](./pyjsex.gif)\r\n\r\nIn case you aren't familiar these are examples of Json, a JS Object and a Python dictionary to show that they all have the exact same syntax.\r\n\r\n[**Json (JavaScript Object Notation)**](#json)\r\n```json\r\n{\r\n    \"name\": \"json\",\r\n    \"msg\": \"Hello, world I'm Json\"\r\n}\r\n```\r\n[**Python Dictionary {}**](#python-dict)\r\n```python\r\nnote = {\r\n    \"name\": \"python\",\r\n    \"msg\": \"Hello, world I'm Python\"\r\n}\r\n```\r\n\r\n[**JavaScript Object {}**](#javascript-object)\r\n```javascript\r\nlet note = {\r\n    \"name\": \"javascript\",\r\n    \"msg\": \"Hello, world I'm JavaScript\"\r\n}\r\n```\r\n---\r\n\r\n## [Usage](#usage)\r\n\r\nBoth the `JS` and the `Py` classes have the exact same functionality and contain the same methods and properties as follows:\r\n\r\n### [JS Class Attributes](#js-class-methods)\r\n- `JS.NOTE` - This is where the retieved data from Py is stored\r\n- `JS.JSON_PATH` - This will store the path passed to checkForNote()\r\n- `JS.sendNoteToPy(note_object, path)`\r\n- `JS.getNoteFromPy(path)`\r\n- `JS.checkForNote(path)`\r\n\r\n\r\n### [Py Class Attributes](#py-class-methods)\r\n- `Py.NOTE` - This is where the retieved data from JS is stored\r\n- `Py.JSON_PATH` - This will store the path passed to check_for_note()\r\n- `Py.send_note_to_js(self, note_object: dict, path: str)`\r\n- `Py.get_note_from_js(self, path: str)`\r\n- `Py.check_for_note(self, path: str, file: str)`\r\n\r\n---\r\n\r\n## [Examples](#examples)\r\n\r\n### [JS ➟ Py](#js2py)\r\n\r\nTo get an object from **JavaScript** to **Python** do the following:\r\n\r\n1) In your Python program create a new instance of the **Py** class and then call the `check_for_note()` method passing in the path to watch and let it run.\r\n```python\r\npy = Py()\r\npy.check_for_note(\"C:\\\\MyPyApp\\\\\")\r\n``` \r\n   \r\n\u003e \\* NOTE * The `Py.check_for_note` and `JS.checkForNote` methods both have the ability to detect the object/dict being sent from one another, so you can have the `Py.checkForNote` or the `JS.checkForNote` method running already and when the object is sent and it will detect the json file, get the data object, and store it for you.\r\n\r\n\r\n2) Now in your JavaScript program create a new instance of the **JS** class and then call the `sendNoteToPy()` method passing in the object containing whatever data you want as the first argument.\r\n```javascript\r\nconst js = new JS()\r\nsendNoteToPy({\r\n     \"title\": \"Note to Py from JS\",\r\n     \"text\": \"Hello Python!\"\r\n}, \"note_from_js.json\")\r\n```\r\n\r\nOnce the `sendNoteToPy()` method is called the object you passed in will be stored in the ***from_js.json*** file at the specified path and this will automatically be picked up on the Python side by the running `Py.check_for_note()` method from step 1. The data will be stored in the `Py.NOTE` property and accessible from there.\r\n\r\n### [Py ➟ JS](#js2py)\r\n\r\nTo get an object from **Python** to **JavaScript** do the same thing as in [JS ➟ Py](#js2py) but in reverse as follows:\r\n\r\n1) In your JavaScript program create a new instance of the **JS** class and then call the `checkForNote()` method passing in the path to watch and let it run.\r\n```python\r\njs = JS()\r\njs.checkForNote(\"C:\\\\MyPyApp\\\\\")\r\n``` \r\n\r\n2) Now in your Python program create a new instance of the **Py** class and then call the `send_note_to_js()` method passing in the object containing whatever data you want as the first argument.\r\n```javascript\r\npy = Py()\r\npy.send_note_to_js({\r\n     \"title\": \"Note to JS from Py\",\r\n     \"text\": \"Hello JavaScript!\"\r\n})\r\n```\r\n\r\nOnce the `send_note_to_js()` method is called the object you passed in will be stored in the ***from_py.json*** file at the specified path and this will automatically be picked up on the JavaScript side by the running `JS.checkForNote()` method from step 1. The data will be stored in the `js.NOTE` property and accessible from there.\r\n\r\n## [Python \u0026 JavaScript Use Cases](#use-cases)\r\nUsing Python and JavaScript together can be pretty powerful and flexible, as each language has its own strengths and use cases. Below are some common scenarios where combining Python and JavaScript can provide benefits:\r\n\r\n### [Web Development:](#web-development)\r\n\r\n* **Backend (Python) and Frontend (JavaScript):** Python can be used for server-side logic, data processing, and business logic, while JavaScript can handle dynamic content, user interaction, and frontend development.\r\n* **AJAX Requests:** JavaScript can make asynchronous requests to Python backend APIs using technologies like [AJAX](https://developer.mozilla.org/en-US/docs/Web/Guide/AJAX) (*Asynchronous JavaScript and XML*) to update specific parts of a webpage without requiring a full page reload.\r\n\r\n### [Data Visualization:](#data-visualization)\r\n\r\n* **Python Data Processing + JavaScript Visualization Libraries:** Python is often used for data processing and analysis using libraries like **NumPy**, **pandas**, and **Matplotlib**. Once data is prepared, it can be visualized using JavaScript libraries like **D3.js**, **Plotly**, or **Chart.js** for interactive and dynamic visualizations in web applications.\r\n\r\n### [Full-Stack Applications:](#full-stack-applications)\r\n\r\n* **Single Page Applications (SPAs):** Using frameworks like **Django (Python)** for backend and **React** or **Vue.js** (JavaScript) for frontend allows developers to create seamless, efficient, and interactive [SPAs](https://en.wikipedia.org/wiki/Single-page_application) where the two languages work together to deliver a cohesive user experience.\r\n\r\n### [Machine Learning and AI:](#machine-learning-and-ai)\r\n\r\n* **Python Backend for Model Inference:** Python's extensive machine learning and AI libraries like **TensorFlow**, **PyTorch**, and **scikit-learn** can be used to build and train models. JavaScript can then be used to deploy these models in web applications for real-time predictions and interactive user experiences.\r\n\r\n### [Cross-Platform Desktop Applications:](#desktop-applications)\r\n\r\n* **Python Backend + Electron (JavaScript) Frontend:** Combining Python with [Electron](https://www.electronjs.org/) (*a framework for building cross-platform desktop applications using web technologies*) allows you to create desktop applications that have a Python backend and a JavaScript-based frontend.\r\n\r\n### [Embedded Widgets and Widgets in Content Management Systems:](#content-management-systems)\r\n\r\n* **Embedding Interactive Elements:** Python can be used to generate dynamic content or widgets, which can then be embedded in websites or content management systems using JavaScript. This is particularly useful for incorporating custom functionality or interactivity.\r\n\r\n## [Benefits of Using JavaScript with Python](#benefits)\r\n\r\n![programming art](416e041e-cac5-417c-bc7a-dc4b7e280f52.png)\r\n\r\nProgramming is like art in a way. You're not locked into building specific things in specific ways, but rather you have the abilty to build what you want and how you want. Programming languages are flexible enough that you can do the same thing many different ways, whatever that thing your doing is. You can build a desktop app - frontend and backend - entirely with JavaScript, but I wanted to focus on using Python and JavaScript together so the following are some benefits I can think of.\r\n\r\n### [Leveraging Strengths:](#leveraging-strengths)\r\n Python is known for its data processing, scientific computing, and machine learning capabilities, while JavaScript is known for its ability to create interactive and dynamic user interfaces. By combining these strengths, you can create more feature-rich and interactive applications. As I mentioned previously, it opens up a lot of possibilities.\r\n\r\n### [Ecosystem Diversity:](#ecosystem-diversity)\r\n Both Python and JavaScript have vast ecosystems of libraries, frameworks, and tools. Combining them allows you to choose the best tools for each part of your application, optimizing for performance, functionality, and developer familiarity.\r\n\r\n### [Flexibility:](#flexibility)\r\nUsing both languages enables you to address a wider range of challenges and create more versatile applications.\r\n\r\n### [Separation of Concerns:](#seperation-of-concerns)\r\n Separating backend logic (Python) from frontend presentation (JavaScript) follows the principle of [separation of concerns](https://en.wikipedia.org/wiki/Separation_of_concerns), making your codebase more maintainable and easier to debug.\r\n\r\n### [Scalability:](#scalability)\r\nBy splitting your application into backend and frontend components, you can scale each part independently based on demand, optimizing performance and resource usage.\r\n\r\n## [Contributing](#contributing)\r\n\r\nIf you have any feature requests, suggestions or general questions you can \r\nreach me via any of the methods listed below in the [Contacts](#contacts) section.\r\n\r\n---\r\n\r\n## [Security](#security)\r\n\r\n### Reporting a vulnerability or bug?\r\n\r\n**Do not submit an issue or pull request**: A general rule of thumb is to \r\nnever publicly report bugs or vulnerabilities because you might inadvertently \r\nreveal it to unethical people who may use it for bad. Instead, you can email \r\nme directly at: [paulmccarthy676@gmail.com](mailto:paulmccarthy676@gmail.com). \r\nI will deal with the issue privately and submit a patch as soon as possible.\r\n\r\n---\r\n\r\n## [Contacts](#contacts)\r\n\r\n**Author:** Paul M.\r\n\r\n* Email: [paulmccarthy676@gmail.com](mailto:paulmccarthy676@gmail.com)\r\n* Github: [https://github.com/happycod3r](https://github.com/happycod3r)\r\n* Linkedin: [https://www.linkedin.com/in/paul-mccarthy-89165a269/]( https://www.linkedin.com/in/paul-mccarthy-89165a269/)\r\n* Facebook: [https://www.facebook.com/paulebeatz]( https://www.facebook.com/paulebeatz)\r\n\r\n---\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhappycod3r%2Fjs-loves-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhappycod3r%2Fjs-loves-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhappycod3r%2Fjs-loves-py/lists"}