How to preview (!) a Hype project with PHP connection quickly?


#1

I have a Hype project, where a user moves and turns (kind of divination) cards on the screen.
At a certain moment the user can click a button to make a screenshot (with html2canvas).
The screenshot is sent to a server, where - with the help of PHP - it is saved as a file.
(and then later included in a generated pdf file, which the user can download and save, to keep records, what s/he has done with the cards).

I am confident I can do all of that :wink:
But I need a method to test very quickly.

When I hit cmd+return to see the hype project in a browser, Hype is using a built-in browser at http://127.0.0.1:59946/

But this is not where my php files are.
So I need to export the project to a folder within my local test web server, and then call the local website to see if it works - these are several steps, instead of one.

What I want: my test webserver is used when I hit cmd-return!

I see two possible solutions:
(1) an option in Hype, where I can give a location (where to save the files) and a local webserver URL, so Hype can use these instead of the built-in web server – this option is more work for Tumult – or
(2) knowledge, where Hype stores the preview files. If I could store my PHP files “nearby”, then I can set up a local web server (I use MAMP), pointing to these files. The preview process stores the preview files there, and I hit “reload” in a browser showing these files – this option I could use immediately (also I have a second click to “reload” the browser with my local web server URL --.

Where is the http://127.0.0.1:59946/preview folder in the system?
Can I just create a new folder http://127.0.0.1:59946/preview/myphpfiles?
Then I could have my local webserver pointing to /preview and the hype buttons (as an example) could invoke php scripts on (e.g.) …/myphpfiles/phpscript.php

Thank you for all hints!


#2

How about:

⌘ + shift + e, then hitting enter will re-export your document to its last export location. Then, you can ⌘ + tab over to your browser and hit ⌘ + r to refresh your local PHP instance. That’s as quick as I can imagine this working :slight_smile:

The Preview system exports your document into a dynamic temporary folder which is cleared when restarting your computer so it’s not something you can statically reference.


(Hans-Gerd Claßen) #3

within safaris dev-tools you can disable cross-origin-request-destriction …


(Jonathan Deutsch) #4

This idea came from a private chat @daniel and I had… it might be possible to use the Export Scripts mechanism to get this behavior. Export scripts allow modifying the exported files on the way out, including during previews. There’s specifically a call with the --modify_staging_path argument that will get a filesystem path to all the files of the preview/export, which you could then use to copy the files to a place where you are serving the PHP.

The trickier part would be disabling Hype from opening up its preview automatically. One approach would be to simply have the Export Script call another script in a delayed fashion that would run. This could be an apple script that would look at your browser tabs and replace the Hype preview URL with the PHP one you want.


#5

Thank you, Daniel. I will do that - quick and simple :wink:
(sometimes it’s hard to see the wood and not only all the trees…)


#6

Thank you, jonathan! I will keep the Export Scripts in mind for more complex preview and export solutions. For now Daniel’s solution does it for me good enough…