Skip to main content

Python library that provides a simple way to render HTML content in a web browser.

Project description

render_html

render_html is a Python library that provides a simple way to render HTML content in a web browser. It allows you to open HTML content directly from a string or save it to a file and open it from the file. You can also specify the name of a browser to use a non-default browser. Please refer to webbrowser documentation for the complete list of predefined browsers. This library is especially useful for quickly visualizing and testing HTML content in a web browser environment.

Installation

You can install render_html using pip:

pip install render-html

NOTE: the library requires Python 3.10 or newer

Usage

from render_html import render_in_browser as ren
import requests

# Making a request with the requests library
response = requests.get('https://example.com')

# Rendering the HTML response in the default browser
html_content = response.text
ren(html_content)

Documentation

render_in_browser(html_string, save_path=None, browser=None)

Render the HTML content in a web browser.

  • html_string (str): The HTML content as a string.
  • save_path (str, optional): The path to save the HTML content as a file. If provided, the HTML content will be saved to the specified file and opened from it. If not provided or set to None, a temporary file will be created in the operating system's default temporary directory. The temporary file will be removed once the rendering is complete.
  • browser (str, optional): The name of the web browser to use (i.e., "chrome", "safari"). If provided, the HTML content will be opened using the specified browser. If not provided or set to None, the default browser will be used.

License

This project is licensed under the MIT License. See the LICENSE file for details.

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

render_html-1.0.1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

render_html-1.0.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file render_html-1.0.1.tar.gz.

File metadata

  • Download URL: render_html-1.0.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for render_html-1.0.1.tar.gz
Algorithm Hash digest
SHA256 ae7119b53566f84dc172480a1d8a3cc1fd8d5d3661f2a8537efb24114e97f17f
MD5 06b8d9c7f3551584b5b6a8c4a8445802
BLAKE2b-256 6998d8b35afedeacf6ee66d9a7eda1e378031188668153b144041b8ae32d4871

See more details on using hashes here.

File details

Details for the file render_html-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: render_html-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for render_html-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c7fc7275931964414a94edc158955c61643fe981eca7e2c65f9311331be77986
MD5 975ace193aa05b8ad385be786a727edc
BLAKE2b-256 096d920493775bbdb30caf31b490e036566382c7b293b63878e5b02bc13c2d92

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