# Serving Static Sites

> Serves plain static HTML/CSS/JS files to the user when a full framework is overkill. Use for a single landing page or quick prototype — never use python -m http.server, it exposes a directory listing.

- Skill: `aaravriyer193/serving-static-sites` (Agent Skill)
- Install (CLI): `npx skillmds@latest add aaravriyer193/serving-static-sites`
- Raw SKILL.md: https://api.skillmd.com/api/skills/aaravriyer193/serving-static-sites/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Web & Frontend
- Author: aaravriyer193 (https://skillmd.com/u/aaravriyer193)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/aaravriyer193/serving-static-sites

---


# Serving static sites

`python -m http.server` exposes a raw directory listing of the whole folder to anyone who opens the URL — looks broken and leaks more than intended. Use a two-line Flask app instead:

```python
from flask import Flask, send_from_directory

app = Flask(__name__)

@app.route("/")
def index():
    return send_from_directory(".", "index.html")

@app.route("/<path:path>")
def static_file(path):
    return send_from_directory(".", path)

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=8000)
```

```bash
pip install flask
```

Run it backgrounded from the folder containing the site, then open_port on 8000:
```
shell: cd /home/user/site && python app.py    (background: true)
open_port: 8000
```

