diff options
| author | yyamashita <yyamashita@hetzner.yyamashita.com> | 2026-11-01 09:11:55 +0900 |
|---|---|---|
| committer | yyamashita <yyamashita@hetzner.yyamashita.com> | 2026-11-01 09:11:55 +0900 |
| commit | f0044f886359d942fe479a9a8a940af17c7047ac (patch) | |
| tree | 842127fdeca489e41ca9b126d8894eafedc64e72 /server.py | |
| parent | e22ef944f0c86a8f7a6f33e9689414659dcc167c (diff) | |
Docker で動かせるようにする
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'server.py')
| -rw-r--r-- | server.py | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -2,9 +2,11 @@ python3 server.py # http://localhost:8000 python3 server.py 8080 # ポート指定 + HOST=0.0.0.0 python3 server.py # コンテナ内など外から受ける場合 """ import json +import os import sys from datetime import date from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer @@ -59,5 +61,6 @@ class Handler(SimpleHTTPRequestHandler): if __name__ == "__main__": port = int(sys.argv[1]) if len(sys.argv) > 1 else 8000 - print(f"http://localhost:{port}") - ThreadingHTTPServer(("127.0.0.1", port), Handler).serve_forever() + host = os.environ.get("HOST", "127.0.0.1") + print(f"http://{host}:{port}", flush=True) + ThreadingHTTPServer((host, port), Handler).serve_forever() |
