Jump to content

Web Server ( Easily start a web server and add files to it )

Recommended Posts

Web Server

Easily start a web server and add files to it (v 1.3.6)




Update 1.3.6:


- Port number wasn't copying to clipboard when checking the IP Address.


Update 1.3.5:


- New and Better IP addresses checker. My Thanks and Credits to Shawn Rice.

- Now php.ini and index.php files are hidden as well.

- Fixed some other bugs. I hope the initial setup works properly now.


Update 1.3.4:


- Uploads won't overwrite existing file with same name anymore.

- Moved user defined port file to Workflow data storage.


Update 1.3.3:


- Auto-refresh page after upload is completed!

- New notification banner saying "Upload Completed". Yay.



Update 1.3.2:


- Upload feature revamped. Now you can Drag and Drop files and then upload :D You can even rename them before uploading.

- It seems PHP has upload and memory limit. So uploading big files wasn't working. Hopefully everything works now. Or at least 2GB files.



Update 1.3.1:


- HUGE mistake. Sorry. The last update wasn't copying the new files to the Server folder.



Update 1.3:


- Added ability to Upload files

- Now you can check your Local and External IP addresses

- Set the Server Port number to any Port you want



Update 1.2.1:


- ***CRITICAL*** Fixed huge typo bug. The server wouldn't stop if your local IP address didn't start with "10" :(



Update 1.2:


- Fixed an issue with the File Action "Add Files to Web Server".



Update 1.1:


- Changed Server folder location to Workflow Data storage. (Thanks, Shawn)

- Added Readme content.






- Mavericks or any prior OS X with PHP 5.4 




The default server's port is set to 21025. To access the web server folder, open your browser and go to your local IP address at the mentioned port. Example: ""


You can access your Web Server folder from any computer in the same network. If you want people from outside your local network to be able to access your Web Server folder, you have to clear the port in your router's settings (Google "port forwarding"). After clearing the port, use your external IP address instead of your local IP address. Example: ""


Also, the Web Server allows you or people who are accessing it to upload files, as long as the file is an allowed extension. This limitation is for security purpose.




+ Keywords:

- "server": Lets you start the server (if it's not running) or stop the server (if it's running).


- "server open": Open the Web Server folder. This is where you put the files you want to share.


- "add": Copy files selected in Finder to the Web Server folder.


- "server ip": Check what's your Local and External IP address.


- "set port": Set the Web Server port number to any port within the valid range of 0 and 65535, so long as it doesn't conflict with an already assigned port.


+ File Action:

- "Add Files to Web Server": Copy selected files to the Web Server folder.












Download link:






Any feedback is welcome.

Edited by MaximiliumM
Link to comment

This is pretty clever. Kudos.


Two things:


1) This will work only on Mavericks. Reason: Mavericks finally upgraded its php to 5.4, which includes the built-in webserver. All versions before that have php 5.3, which doesn't have this feature. If you're running something pre-Mavericks, then you can make this work by upgrading PHP, and the easiest way to do that is to upgrade to Mavericks. After all, it's free.


2) Max, you might consider moving the server folder. Right now, it places all information inside the workflow folder itself, which potentially causes problems with upgrading / exporting. Instead, consider putting the server path at the recommended storage place:

~/Library/Application Support/Alfred 2/Workflow Data/fmanoeli.webserver

Just add in a line into the Applescript to check for the folder's existence, and, if not, to create it.


Looking forward to using it.



Link to comment



Thanks for clearing that PHP 5.4 thing out. I didn't know that.


And about your second point, yeah, I knew that... Today while using it I thought it could cause problems when exporting the Workflow and so on, but unfortunately I haven't got time to fix it yet.


I'll have everything fixed by tomorrow.


Thanks :)

Link to comment

Here's the quick fix. I think this should cover it:


Change the serverPath variable everywhere to this line:

set serverPath to POSIX path of ((path to "cusr" as text) & "Library/Application Support/Alfred 2/Workflow Data/fmanoeli.webserver/ServerFolder" as text

And, at the beginning of the scripts that initialize anything, add the line

do shell script "bash run.sh"

And, lastly, add this into a file called "run.sh" in the workflow folder


# set the folder
nv="/Users/$USER/Library/Application Support/Alfred 2/Workflow Data/fmanoeli.webserver"

# first run not completed. Start.
if [ ! -d "$nv" ]
  # make the directory
  mkdir "$nv"
if [ ! -d "$nv/ServerFolder" ]
  # copy the template directory from the workflow folder
  cp -R ServerFolder "$nv"
  # can't remember if you'll need this... if the hidden files don't copy, then uncomment it
  # cp -R ServerFolder/.images "$nv/ServerFolder"
  # cp ServerFolder/.images/.index.php "$nv/ServerFolder/.images"
  # cp ServerFolder/.htaccess "$nv/ServerFolder"
  # cp ServerFolder/.error.php "$nv/ServerFolder"
  # cp ServerFolder/.sorttable.js "$nv/ServerFolder"
  # cp ServerFolder/.style.css "$nv/ServerFolder"

That should do it.


The bash script will make sure that the folder exists, and if it doesn't, then it'll make it and copy the "template" directory to the directory.

Link to comment

Haha. Thanks for the code. But I've already fixed it. I'll check your code anyway, maybe it's better than mine :P


About the PHP 5.4 requirement. I've added the information to the main post.


Also, I had another really simple Workflow that would run the command "python -m SimpleHTTPServer 21025", but there was no CSS style file, so its appearance was just a list of files and really ugly ;( 


Thanks again. If you find more bugs or any improvement that can be made, please tell me :) And check my other Workflows, if you want. I'd love to have more feedbacks like yours :)

Link to comment
  • 2 weeks later...

Seems like it has to do with file upload size. My research keeps turning up the same thing "change php.ini", but not sure what to do here. I tried putting a php.ini inside the ServerFolder and changed it file upload limit size, but it didn't work.


Anyone with more experience?



Link to comment

Thanks, Shawn. Hopefully I got it working.


Update bump again.


Update 1.3.2:
- Upload feature revamped. Now you can Drag and Drop files and then upload  :D You can even rename them before uploading.
- It seems PHP has upload and memory limit. So uploading big files wasn't working. Hopefully everything works now. Or at least 2GB files.
Link to comment
  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...