Skip to content

Instantly share code, notes, and snippets.

@chockenberry
Created April 6, 2022 17:32
  • Star 17 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
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.
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
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