Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rnelson/server
A small server script to host content in a directory, with some extras
https://github.com/rnelson/server
Last synced: 12 days ago
JSON representation
A small server script to host content in a directory, with some extras
- Host: GitHub
- URL: https://github.com/rnelson/server
- Owner: rnelson
- License: mit
- Created: 2015-09-07T14:34:02.000Z (over 9 years ago)
- Default Branch: main
- Last Pushed: 2024-07-09T18:12:58.000Z (7 months ago)
- Last Synced: 2024-07-09T22:52:43.518Z (7 months ago)
- Language: Python
- Size: 26.4 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# server
Sometimes, you just need to serve some static content from a directory. When that happens, `python -m SimpleHTTPServer` or `php -S` is pretty handy, but what if you want a little more?This script will handle all of those, but it will also allow you to minify LESS/SASS/SCSS and run Python scripts.
## Installation
server.py requires a recent version of Python 3.
1. Install the dependencies: `python -m pip install -r requirements.txt` (may require `doas` or `sudo`)
2. Clone the repo: `git clone https://github.com/rnelson/server.git`
3. Create a symlink: `ln -s /path/to/server/server.py ~/bin/server`## Usage
Whatever directory you are in when you run the script is the root. This is now available at [http://localhost:9000](http://localhost:9000).
For LESS/SASS/SCSS files, give them the appropriate extension (`.less`, `.sass`, `.scss`) and they'll automatically be minified.
The Python script support relies on `globals()` to pass data from the executing script back to `server`. Two values are read, `output` and `output_type` (the latter defaults to `text/html`) to determine what to display and how to display it. The following is a trivial example:
```
#! env pythoncontent = 'Hello, {}!'.format('World')
globals()['output'] = content
globals()['output_type'] = 'text/plain' # defaults to 'text/html'```
## License
Released under the [MIT License](http://rnelson.mit-license.org).