Your very own file server.
Alfred is simple file server, useful for serving directory over a network. It is an extension of python's
SimpleHTTPServer and allows multiple connections simultaneously. It also support multiple command line arguments for increased flexibility.
(NOTE: You'll be required to install python before you can use alfred. Get it here)
To run using the script, clone this repository (or just download the python script), and place it wherever convenient.
To make Alfred serve the current directory, simple run the following command in your terminal:
$ python alfred.py serve
If you have set up aliases for alfred (see how), you can simply run:
$ alfred serve
To test this, open your broswer and go this url: http://localhost:8021
Alfred supports the following parameters:
-p, --port : Set the port to run the server on. Defaults to 8021 -d, --directory : Specify directory to be served. Defaults to current working directory -c, --count-max : Specify maximum number of times directory can be served -f, --force-port : Force the server to run on the specified port. If this option is used, server won't be started if the port specified is unavailable.
So, say you want to serve your downloads directory on port 11155 and only allow it to be served twice, you would run:
$ python alfred.py serve -p 11155 -c 2 -d ~/Downloads -f
Again, having aliases, this can be simplified as:
$ alfred serve -p 11155 -c 2 -d ~/Downloads -f
To test this, open your broswer and go this url: http://localhost:11155
Setting up aliases
Typing the path to alfred's python script everytime you need to serve a directory can be tedious. So, as a shortcut, you can set a terminal alias.
To create an executable for alfred, download the bash script in this repo. Alternatively, create a new bash file
alfred.sh and add the following lines to it:
#!/bin/sh python /opt/alfred/alfred.py "$@"
- Place the
/opt/alfred/folder, and then place the
alfredscript in your
You may place
alfred.py wherever convenient, just make sure to change the path in the
To test, you can simply run in your terminal:
$ alfred serve
To set up a command line shortcut for Alfred on Windows, the following steps need to be taken.
- Download the bat file in the repo. Alternatively, you can create a batch script by creating a file (say
alfred.bat) and add the following lines to it:
@echo off python "C:\Program Files\alfred\alfred".py %*
- Place the .bat in
C:\Program Files\alfred\, along with the python file (
To make cmd recognize alfred as a command, we need to set a permanent alias for it. For this, do the following:
- Download the aliases file from this repo. Alternatively, create a new file
cmd_aliases.cmd. In this file, add the following lines:
@echo off DOSKEY alfred="C:\Program Files\alfred\alfred".bat $*
The quotes ensure path is interpreted correctly by the command line, and the
$* simple passes all the arguments following the macro to the actual command.
NOTE: To use the --path option of alfred, you would be required to run alfred in an elevated command line. This is required since single fiels are served using symlinks, and Administrator priviledges are required in Windows to create them.
You can also add other aliases you may want to set up to this file. See this for more on doskey macros
Place this .cmd file in your AppData folder (reach it by typing
%AppDatain the Windows address bar)
To make this .cmd file run automatically, open the Run prompt (Windows key + R) and type
regeditand hit enter.
Navigate to HKEY_CURRENT_USER -> Software -> Microsoft -> Command Processor.
Create a new entry here by Right Click -> New -> Expandable String Value. Set the name as
AutoRunand the data as the path to your .cmd file (if you're following the steps as they are, it should be
That's it. Close the Registry Editor window, close any other terminals you opened, for the changes to take effect.