Skip to main content

A simple module for serving HTML and managing dependencies with Flask.

Project description

Here's your updated README.md file based on the format you provided:

# **HarmonixPy**

**HarmonixPy** is a Python library designed to simplify the process of managing external files (e.g., HTML, CSS, JS, Python, dependency files) in Python projects. It provides a seamless way to load and serve HTML files using Flask while automating the installation of dependencies from a `requirements.txt` file. It also allows you to customize the paths for HTML, CSS, JS, and Python files for greater flexibility.

This library is ideal for developers working on lightweight backend projects or environments like **Pydroid**, which have limited support for external files.

---

## **Key Features**
- **File Management:** Load and serve external HTML, CSS, JS, Python files in your Python project with minimal effort.
- **Flask Integration:** Dynamically serve HTML files using Flask’s `render_template_string`.
- **Dependency Automation:** Automatically install required dependencies from a `requirements.txt` file using `subprocess`.
- **Customizable Paths:** Flexible configuration for specifying the paths of your HTML, CSS, JS, Python files.
- **Default File Creation:** Automatically creates default HTML, CSS, JS, Python files if not provided.

---

## **Installation**
Install **HarmonixPy** using pip:
```bash
pip install harmonixpy

Quick-Start Example

Here’s how to use HarmonixPy in your project:

Step 1: Create Your HTML, CSS, JS, Python Files

  • Save your HTML file (e.g., templates/index.html).
  • Save your CSS file (e.g., static/styles.css).
  • Save your JavaScript file (e.g., static/scripts.js).
  • Save your dependencies in a requirements.txt file, such as:
    flask
    requests
    beautifulsoup4
    

Step 2: Write Your Python Code

from harmonixpy import HarmonixPy

# Initialize the library with file paths
HarmonixPy(
    html_file="templates/custom_index.html",  # Path to the HTML file
    css_file="static/custom_styles.css",      # Path to the CSS file
    js_file="static/custom_scripts.js",       # Path to the JavaScript file
    requirements_file="custom_requirements.txt",  # Path to the requirements file
    static_folder="custom_static"             # Path to the static folder
)

Step 3: What Happens Under the Hood

  1. HarmonixPy reads the HTML file and dynamically renders it using Flask.
  2. It parses the requirements.txt file and installs missing dependencies automatically.
  3. The app creates default files (HTML, CSS, JS, Python) if they don’t exist.
  4. A Flask web server is launched to serve the HTML file.

Step 4: Running the App

The app will automatically start and be accessible at http://127.0.0.1:5000/. Open this URL in your browser to see your HTML file rendered as a web page.


Requirements

  • Python 3.7 or higher.
  • Flask (installed automatically via the library).

Functions

HarmonixPy provides the following functions to manage the app configuration:

  • html(file_path): Sets the path to the HTML file.
  • css(file_path): Sets the path to the CSS file.
  • js(file_path): Sets the path to the JavaScript file.
  • dependency(file_path): Sets the path to the requirements.txt file.
  • create_default_files(): Creates default HTML, CSS, JS, Python files if not already present.
  • run(host="127.0.0.1", port=5000): Runs the Flask app at the specified host and port.

Usage Example with Individual Functions:

import harmonixpy as hmnx

# Set custom paths for HTML, CSS, JS, Python files
hmnx.html("templates/custom_index.html")
hmnx.css("static/custom_styles.css")
hmnx.js("static/custom_scripts.js")

# Set the requirements file and static folder
hmnx.dependency("custom_requirements.txt")
hmnx.run()  # Start the Flask app

Contributing

We welcome contributions! Please refer to the contributing.md file for guidelines on reporting issues, submitting pull requests, or participating in discussions.


License

This project is licensed under the Apache License. See the license.md file for more details.


Changelog

  • Version 0.0.4: Cleaned out the bug and improved multiple file handling
  • Version 0.0.2: Added support for CSS, JS, and Python file paths in the HarmonixPy initialization.(had a bug)
  • Version 0.0.1: Initial release with HTML and dependency file handling.

This updated README.md reflects the new functionality and flexibility introduced in HarmonixPy. It covers how to initialize the library with custom HTML, CSS, JS, Python files, as well as the new, simplified usage patterns for users.


This version adds:
- The title and description of the library.
- An updated installation section.
- A more detailed explanation of how the library works with quick-start steps and explanations.
- A section on the various functions you can use with the library.
- Changelog for versioning updates. 

This should now be clear and informative for new users, with a structured and easy-to-follow setup.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

harmonixpy-0.0.5.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

HarmonixPy-0.0.5-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file harmonixpy-0.0.5.tar.gz.

File metadata

  • Download URL: harmonixpy-0.0.5.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.4

File hashes

Hashes for harmonixpy-0.0.5.tar.gz
Algorithm Hash digest
SHA256 205bb40669a502ac5fcf663da79f4ba3b50929c27dcb82b2b2c90a087d5ff583
MD5 05c2f619fa92a813594785e4c08c739b
BLAKE2b-256 4cb2f02e6653eae9de7684219949e8497df2b45d756445a4754db6a7d10b3556

See more details on using hashes here.

File details

Details for the file HarmonixPy-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: HarmonixPy-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.4

File hashes

Hashes for HarmonixPy-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 52fd6520897e7b7b578513e18eff72941084e29c40beb5bae6b0f5a777596d76
MD5 4262212ce375d18d6789d630c0899d0f
BLAKE2b-256 531f7799e810c657a916d2081e7c49fd8d4be800fd808d58a368b6f2586db551

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page