Publishing
Apps created from Hex projects have a sense of versioning, including a currently "Published" version.
This published version is the only viewable page for users with App Only permissions.
Updating the published version
The Publish button will appear anytime there are unpublished changes in a project.
Clicking this button, you will be presented with the option to publish your changes, along with a live preview of your changes and a link to the currently-published version of your app for reference.
You can view and revert to past versions of a project using the Version control dialog.
Force publish
Clicking Publish sets off an app run that displays output and any potential errors before promoting the current version to the published app. While the app is running, the Publish button will say "Running...", with a down arrow and Force publish button. The Force publish option forces the app to publish without waiting for the run to complete in the publish dialog. Note that this will not kill the run that has been kicked off; it will simply allow you to publish and exit the publish modal before the run completes.
Force publishing takes away the ability to review any unexpected app behavior or errors before updating the published app.
Seeing an error in the Publish preview, but you just ran things and swear it works? Apps (and previews) always run every cell in your Logic top-to-bottom with a new kernel. This means there may have been now-deleted variables lingering in your personal kernel, leading to errors in the new kernel. Try to go back to the Logic View and Restart and run all to pinpoint the problem.
Schedule published apps
You can use Hex to schedule runs on a periodic basis. It's important to note that scheduled runs will execute the currently-published version of the logic, which may differ from the version you're viewing.
Share links to a published app
Hex lets you generate several different types of links for easy reference to your published app. Which type of link you need will depend on what view of the published app you'd like to share. There are three options for link generation: Published app, Current inputs, & Live session.
Published app
This option generates a link to your published app with all input parameters set to their default values and copies it to your clipboard. Any changes which have been made to the inputs of a published app that are different from the default values will not be reflected when using this link.
Live session
This option both refreshes your published app session to be a live session as well as generates a unique link to that new live app session. You can send this new link to team members to let them join the same view of the app as you. Team members viewing the same live session will see any changes made by any user in that session in real-time.
Current inputs
This option generates a link that includes the current values of all input parameters in the app specified as URL parameters. When following this link, a new app session will be started with these values. Once the app has loaded, the input parameters which were specified in the generated link as URL params will be removed from the current page URL, and it will effectively become the Published app link type (see above).
Input parameters as URL parameters
In addition to the option to generate a preconfigured URL based on your current app inputs as described above, you can also manually construct an app URL by representing input parameters and their values as URL parameters. However, you must ensure that each URL parameter conforms to the supported configuration for each type of input parameter, as described below. If an invalid URL parameter is passed that parameter is ignored.
Input parameters are referenced in the URL via their corresponding python variable name, prefixed with an underscore, e.g. https://app.hex.tech/{workspace_id}/hex/{project_id}/latest?_{variable_name}={variable_value}. You can pass multiple input parameter values as URL parameters by appending parameters to a published app URL after a ?
, and separating each parameter with a &
.
When specifying an input parameter value inside of an embed src
string, you'll need to UTF-8 encode the parameter value. This includes using the UTF-8 character for double quotes, %22
, instead of double quotes.
Input parameter | Example URL parameter | Notes |
---|---|---|
Checkbox | /latest?_input_checkbox=false | true/false are the only accepted values |
Run button | /latest?_input_button=true | true/false are the only accepted values |
Dropdown | /latest?_input_dropdown=42 | Strings must be wrapped in quotes. |
Multi-select | /latest?_input_multiselect==["b",99] | Values must be passed as a JSON-encoded array. Strings must be wrapped in quotes. |
Number | /latest?_input_number=123.456 | |
Slider | /latest?_input_slider=4 | If a value outside of the Slider's defined range is provided the default value is used instead. |
Text | /latest?_input_text="It is a truth universally acknowledged..." | Strings must be wrapped in quotes. |
Date - no time | /latest?_input_date_only="2021-07-13" | Dates must be passed with a "YYYY-MM-DD" format |
Datetime - with timezone | /latest?_input_datetime_tz="2021-07-13 13:45:22 America/Chicago" | Datestimes with a timezone must be passed with a "YYYY-MM-DD HH:MM:SS {timezone name}" format |
Datetime - without timezone | /latest?_input_datetime="2021-07-13 13:45:22" | Datetimes without timezone information default to UTC, must be passed with a "YYYY-MM-DD HH:MM:SS {timezone name}" format |
Relative date - with timezone | /latest?_relative_date_tz="7 days ago America/Chicago" | Relative dates with a timezone must be passed with a format of: {number} [day(s), month(s), year(s)][ago, from now] {timezone name} and wrapped in quotes. |
Relative date - without timezone | /latest?_input_datetime="2021-07-13 13:45:22" | Relative dates without a timezone must be passed with a format of: {number} [day(s), month(s), year(s)][ago, from now] and wrapped in quotes. |