Skip to main content

OpenPost

The OpenPost project is intended to allow the creation of an html POST request file, and optionally open the request in a browser window. The project provides both a Python module for use within a program, and a stand-alone Python script that can be used on the command line.

Python Module

The module provides an OpenPost class object to prepare and submit html POST requests using the default system internet browser. It works by writing a temporary html file locally, and then opens the file in the browser. Upon opening, the file will immediately submit a form via POST to the target url.

Install using:

pip install openpost

OpenPost Object

class openpost.OpenPost(url=None, file_name=None, keep_file=False, time_to_live=5, form_data={}, headers=None, body=None, new_tab=True)

Create a new OpenPost object. All parameters should be passed as keyword arguments. Each parameter is also made available as a property as described below.

Properties

  • {str} OpenPost.body
    Additional lines to be added to the <body> section of the html document. If the value is an array, each element will be added on a separate line.
    (Added in v0.3)

  • {str} OpenPost.file_name
    The path and name to use for the output html file. If no filename is set, it will default to 'OpenPost.html' in the current directory.

  • {dict} OpenPost.form_data
    The key:value data to include in the POST request html form. Each key will be entered as a separate item in the form.

  • {str} OpenPost.headers
    Additional lines to be added to the <head> section of the html document. If the value is an array, each element will be added on a separate line.
    (Added in v0.3)

  • {bool} OpenPost.keep_file
    An indicator as to whether or not to keep the output html file after opening in browser.

  • {bool} OpenPost.new_tab
    An indicator as to whether or not to open the page in a new browser tab. Note that some browsers will force opening in a new tab regardless of this setting.
    (Added in v0.3)

  • {float} OpenPost.time_to_live
    The number of seconds to delay before removing the output html file (0-60). This is ignored if the keep_file property is set to True.

  • {str} OpenPost.url
    The url for the action field in the html form.

  • {bool} OpenPost.written
    An indicator as to whether or not the html file has already been written.
    (Depricated since v0.3)

Methods

  • OpenPost.clear_data()
    Clears the data used for the POST request form.

  • OpenPost.add_key(key, value)
    Add or update a data key used for the POST request form.
    Arguments:

    • {str} key -- Key used in the form
    • {str} value -- Value for the specified key
  • OpenPost.delete_key(key)
    Remove a data key used for the POST request form.
    Argument:

    • {str} key -- Key to be removed from the form
  • OpenPost.make_html()
    Make the content of the output html file.
    Returns a string containing the content of the html file, or '' if an error occurred.

  • OpenPost.write_html()
    Prepare and write the output html file.
    Returns True if the file was successfully written, otherwise False.

  • OpenPost.send_post()
    Open the output POST html file in the default web browser, automatically writing the output html file if it has not already been written. Automatically removes the output file after the specified time delay unless the keep_file flag has been set.
    Returns True if the file was successfully opened, otherwise False.

  • OpenPost.version()
    Returns the version number of the openpost module.

Example

import openpost

poster = openpost.OpenPost()
poster.url = 'https://www.somesite.org/login.php'
poster.file_name = 'my_special_filename.html'
poster.add_key('name', 'My Name')
poster.add_key('id', 'My_ID')
poster.add_key('password', 'My_Secret_Password')
poster.body = r'<p>You are being redirected.  Please stand by...</p>'
if poster.send_post():
  print('POST request sent.')
else:
  print('Error sending POST request.')

Command Line Utility

This utility allows you to open a POST request in a browser window from the command line. It works by writing a temporary html file locally, and then opens the file in the browser. Upon opening, the file will immediately submit a form via POST to the target url.

Please see the repository on GitHub for full usage information and to download.

Metadata

Release files for openpost 0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openpost 0.3
File Size Uploaded Provenance
openpost-0.3.tar.gz 8.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for openpost 0.3
File Interpreter ABI Platform
openpost-0.3-py3-none-any.whl Python 3 none any Details

Total release size: 15.0 kB

Release files / openpost-0.3.tar.gz

Download URL openpost-0.3.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
093eb3b6ca9127eed4f16ea912309e44957a2fdc0620773a18813e9a29e98e3b
BLAKE2b-256 checksum
How to use checksums
3f43fb941d1ecbb99c1bf2a30870123574ec075c8a76ff3c2399db0b8cdfa6f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.3.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.6

Release files / openpost-0.3-py3-none-any.whl

Download URL openpost-0.3-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fb26a2f4ebc64721aa047cbf93540780d752f75a103ceb77d20fd4a507385aab
BLAKE2b-256 checksum
How to use checksums
d78cb68f798e0775403155936e283cffa6d1b4e8328b75f5662874a16e3ca96c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.3.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.6

Security for openpost 0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page