Created
April 6, 2022 17:32
-
-
Save chockenberry/9a2b72c7a3d324f9d306e98d5259821d to your computer and use it in GitHub Desktop.
A simple AppleScript to start up a web server in the folder where the script is located.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) Add this code to a new file in Script Editor | |
2) Export the script as "Application" and make sure it's code signed | |
3) Put "Startup.app" in the root folder of the test website (e.g. where index.html is located) | |
4) Make sure that "Startup.app" has Full Disk Access in System Preferences > Security & Privacy > Privacy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "Finder" to set basePath to (POSIX path of (parent of (path to me) as string)) | |
do shell script "cd " & basePath & "; /usr/bin/ruby -run -ehttpd . -p8080 &> /dev/null & echo $!" | |
set pid to the result | |
do shell script "/usr/bin/open http://localhost:8080 &> /dev/null &" | |
display dialog "Click OK when done testing in " & basePath buttons {"OK"} | |
do shell script "kill " & pid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment