Created
March 8, 2024 20:48
-
-
Save ricardomaia/f3a1ed228848eebfecfd64e43fd322e7 to your computer and use it in GitHub Desktop.
Expose current directory on web
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const fs = require('fs'); | |
const app = express(); | |
const port = 3000; | |
app.get('/', (req, res) => { | |
fs.readdir('.', (err, files) => { | |
if (err) { | |
res.send('Erro ao ler diretório'); | |
} else { | |
let html = '<h1>Arquivos no diretório corrente:</h1>'; | |
files.forEach(file => { | |
html += `<p>${file}</p>`; | |
}); | |
res.send(html); | |
} | |
}); | |
}); | |
app.listen(port, () => { | |
console.log(`Aplicação rodando em http://localhost:${port}`); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$dir = '.'; | |
$files = scandir($dir); | |
echo "<h1>Arquivos no diretório corrente:</h1>"; | |
foreach ($files as $file) { | |
echo "<p>$file</p>"; | |
} | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
import os | |
app = Flask(__name__) | |
@app.route('/') | |
def list_files(): | |
files = os.listdir('.') | |
html = '<h1>Arquivos no diretório corrente:</h1>' | |
for file in files: | |
html += f'<p>{file}</p>' | |
return html | |
if __name__ == '__main__': | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment