Host static content from Dropbox or Google Drive locally.
Static is a command line tool to serve static files from Dropbox or Google Drive.
Static indefinitely caches each file and is constantly polling each root directory to detect for file changes.
The program takes a path (or multiple) to a single directory and serves each file from that directory.
Example:
-
Assume you have a
/site
folder on your Dropbox account with the following contents:index.html
,style.css
,image.png
. -
You run the following to start Static:
$ static -service=dropbox -path=/site -endpoint=/ Listening on port 3030.
-
You can now access each of the files at:
http://localhost:3030/index.html
,.../style.css
, or.../image.png
. -
Relative references also work as expected. So if
index.html
imported fromstyle.css
, the CSS would appear as you'd expect. -
In this example, we're constantly pinging the Dropbox server to detect for changes in the
/site
directory.
-
Go should be installed and configured.
-
Install with Go:
$ go get -v github.com/kshvmdn/static $ static # binary file is located in $GOPATH/bin
-
Or, install directly via source:
$ git clone https://github.com/kshvmdn/static.git $GOPATH/src/github.com/kshvmdn/static $ cd $_ # $GOPATH/src/github.com/kshvmdn/static $ make install && make $ ./static
-
View the help dialogue by running the program with
-help
.$ static -help Usage of ./static: -config string Optional config. file for multiple paths & endpoints. -endpoint string Endpoint to serve content at. (default "/") -path string Dropbox path to serve content from. -port int Server port. (default 3030) -refresh-on-dir-change Refresh on directory change. The alternate (when false) is to only refresh a file when the file itself changes. (default true) -service string Service to be used ("dropbox" or "drive"). -sleep int Time to wait between polls (in seconds).
-
The program takes one (and only one) of the following:
-
Command line flags for both
-path
and-endpoint
to define where to find the content (path) and which endpoint to serve them at (endpoint). -
A JSON or YAML config. file with one or multiple paths and endpoints.
-
Example JSON file:
[ { "path": "/personal-site", "endpoint": "/" }, { "path": "/test", "endpoint": "test" } ]
-
And the same contents in a YAML file:
- path: /personal-site endpoint: / - path: /test endpoint: test
-
-
-
Head over to this page and create a new Dropbox app with the following settings:
- API: Dropbox API
- Access: Full Dropbox
- Name: anything
-
You'll need to export the app key, app secret, and access token as environment variables.
DROPBOX_APP_KEY=<app key> DROPBOX_APP_SECRET=<app secret> DROPBOX_ACCESS_TOKEN=<access token>
Not yet implemented.
This project is completely open source, feel free to open an issue for questions/features/bugs or submit a pull request.
Prior to submitting work, please ensure your changes comply with Golint. You can use make lint
to test this.
- Add Google Drive integration, refer to this to get started. Requires OAuth2, might be worth it to use OAuth2 for Dropbox as well to be consistent.
- Rework the long poll model. Currently polls each directory path (not file!), which means every file in a given path polls the same root directory. This can be fixed by starting the polling when a file is first accessed (since that's when the associated key is created). We'll just need to track which keys are being polled, which shouldn't be a problem.