Skip to content

Instantly share code, notes, and snippets.

@ricardomaia
Last active February 8, 2026 04:32
Show Gist options
  • Select an option

  • Save ricardomaia/b5f21135e7292af4f27f73bf4c2db1b6 to your computer and use it in GitHub Desktop.

Select an option

Save ricardomaia/b5f21135e7292af4f27f73bf4c2db1b6 to your computer and use it in GitHub Desktop.
One line Python HTTP server

Servidores HTTP Simples – Comandos em Uma Única Linha

Python

Python 3

python3 -m http.server 8080 --bind 0.0.0.0 --directory .

Python (padrão)

python -m http.server 8080 --directory .

Shell / Bash

BusyBox (containers e sistemas mínimos)

busybox httpd -f -p 8080 -h .

Netcat (somente demonstração)

while true; do printf "HTTP/1.1 200 OK\r\n\r\n"; ls; done | nc -l -p 8080

PHP (CLI embutido)

php -S 0.0.0.0:8080 -t .

Node.js

http-server (npx)

npx http-server . -p 8080 -a 0.0.0.0

Node.js puro

node -e "require('http').createServer((req,res)=>{const fs=require('fs'),path=require('path');let file=path.join(process.cwd(), decodeURIComponent(req.url.split('?')[0]));fs.existsSync(file)&&fs.statSync(file).isFile()?fs.createReadStream(file).pipe(res):res.end(fs.readdirSync(process.cwd()).join('\\n'));}).listen(8080,'0.0.0.0')"

Java

Java 18+ (jwebserver)

jwebserver --port 8080 --bind-address 0.0.0.0 --directory .

Go

go run -e 'package main; import("net/http"); func main(){ http.ListenAndServe(":8080", http.FileServer(http.Dir("."))) }'

Docker

Python

docker run --rm -p 8080:8080 -v "$PWD:/data" python:3 python -m http.server 8080 --bind 0.0.0.0 --directory /data

NGINX

docker run --rm -p 8080:80 -v "$PWD:/usr/share/nginx/html:ro" nginx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment