Skip to content

Flag to render raw view instead of HTML #97

Description

@dsgibbons

Say I have a local filesystem with

.
├── a.yaml
├── b.yaml
└── c
    └── d.yaml

Running curl localhost:5000 currently outputs something like:

<!doctype html>

<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="generator" content="github.com/patrickdappollonio/http-server 2.1.4">
  <meta name="theme-color" content="#3f51b5">
  <title>HTTP File Server</title>
  <link rel="stylesheet" href="/_/h6y23gab/assets/style.css">
  <link rel="stylesheet" href="/_/h6y23gab/assets/roboto-font.css">
  <link rel="stylesheet" href="/_/h6y23gab/assets/fontawesome-6.2.0.css">
  <link rel="icon" type="image/svg+xml" href="/_/h6y23gab/assets/file-server.svg">
  <link rel="stylesheet" href="/_/h6y23gab/assets/gfm.css">
</head>


<body>

<header>
  <div class="container">
    <nav>
      <a class="page-title" href="/">HTTP File Server</a>
      <ul>
        <li>
          <a href="https://github.com/patrickdappollonio/http-server" rel="noopener" target="_blank"><i class="fab fa-github"></i> Github Repo</a>
        </li>
        <li>
          <a href="https://ghcr.io/patrickdappollonio/docker-http-server" rel="noopener" target="_blank"><i class="fab fa-docker"></i> Container Image</a>
        </li>
      </ul>
    </nav>
  </div>
</header>


<section id="directory-listing">
  <div class="container">

    <div class="card-large">
      <ul class="files">
        <li>
          <span class="files-heading">
            <span class="name"><strong>Name</strong></span>
            <span class="size"><strong>Size</strong></span>
            <span class="date"><strong>Modified</strong></span>
          </span>
        </li>
        <li class="file">
          <a href="/c/" data-name="c">
            <span class="name"><i class="fas fa-folder"></i> c</span>
            <span class="size">-</span>
            <span class="date">Mar 7, 2024 5:48am UTC</span>
          </a>
        </li>
        <li class="file">
          <a href="/a.yaml" data-name="a.yaml">
            <span class="name"><i class="fas fa-code"></i> a.yaml</span>
            <span class="size">0B</span>
            <span class="date">Mar 7, 2024 5:48am UTC</span>
          </a>
        </li>
        <li class="file">
          <a href="/b.yaml" data-name="b.yaml">
            <span class="name"><i class="fas fa-code"></i> b.yaml</span>
            <span class="size">0B</span>
            <span class="date">Mar 7, 2024 5:48am UTC</span>
          </a>
        </li>
      </ul>
    </div>
  </div>
</section>


<footer>
  <div class="container">
    <p>
      Powered by <a href="https://github.com/patrickdappollonio/http-server" target="_blank" rel="noopener"><code>http-server</code></a>
      by <a href="https://www.patrickdap.com/?ref=http-server" target="_blank" rel="noopener">Patrick D'appollonio</a>.
      Icons by <a href="https://fontawesome.com/" target="_blank" rel="nofollow noopener">FontAwesome</a>.
    </p>
  </div>
</footer>


<script src="/_/h6y23gab/assets/code.js"></script>
</body>
</html>

If I use a script to interact with http-server, I need to parse this HTML. Can there be an option like --list-raw or --disable-html, where:

curl localhost:5000

would yield

c/
a.yaml
b.yaml

and

curl localhost:5000/c/

would yield

d.yaml

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions