{"id":18753377,"url":"https://github.com/hanxi/http-file-server","last_synced_at":"2026-03-09T03:36:04.971Z","repository":{"id":36346223,"uuid":"40650963","full_name":"hanxi/http-file-server","owner":"hanxi","description":"use python, upload and download file.","archived":false,"fork":false,"pushed_at":"2015-08-15T04:31:16.000Z","size":114,"stargazers_count":32,"open_issues_count":1,"forks_count":19,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-07-25T07:48:22.925Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hanxi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-13T09:39:49.000Z","updated_at":"2024-07-17T01:31:03.000Z","dependencies_parsed_at":"2022-09-09T23:41:43.847Z","dependency_job_id":null,"html_url":"https://github.com/hanxi/http-file-server","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hanxi/http-file-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanxi%2Fhttp-file-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanxi%2Fhttp-file-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanxi%2Fhttp-file-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanxi%2Fhttp-file-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hanxi","download_url":"https://codeload.github.com/hanxi/http-file-server/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanxi%2Fhttp-file-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30281605,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T02:57:19.223Z","status":"ssl_error","status_checked_at":"2026-03-09T02:56:26.373Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T17:25:34.894Z","updated_at":"2026-03-09T03:35:59.951Z","avatar_url":"https://github.com/hanxi.png","language":"Python","readme":"# HTTP File Server\n\n**http-file-server** 是用 python 实现的 HTTP 文件服务器，支持上传和下载文件。\n\n## 运行\n\n```bash\n$ python file-server.py files 8001\n```\n\n其中第一个参数 `files` 是存放文件的路径，第二个参数 `8001` 是 HTTP 服务器端口。\n\n## 接口\n\n### 1. 读取文件\n\n```\nGET /pathtofile/filename\n```\n\n### 2. 读取文件夹下所有文件（已经忽略隐藏文件）\n\n```\nGET /path\n```\n返回文件列表为 `JSON` 数组，文件名末尾带有 `/` 的表示是文件夹。\n`filename` 为文件名，`mtime` 为修改时间。\n\n```json\n[{\"filename\":\"f1.txt\",\"mtime\":1001},{\"filename\":\"p3/\",\"mtime\":1002}]\n```\n\n### 3. 上传文件\n\n采用 `POST` 方式上传文件，`URL` 参数中传参数 `name` 表示上传的文件名，`POST` 内容为文件内容。\n```\nPOST /upload?name=filename\n```\n\n`ajax` 示例:\n```js\n// file is a FileReader object\nvar data = file.readAsArrayBuffer();\nvar xhr = new XMLHttpRequest();\nvar url = \"http://localhost:8001/upload?name=xxx.md\";\nxhr.open(\"post\", url, true);\nxhr.setRequestHeader(\"Accept\", \"application/json, text/javascript, */*; q=0.01\");\nxhr.onreadystatechange = function() {\n  if (xhr.readyState==4 \u0026\u0026 xhr.status==200)\n  {\n    console.log(xhr.responseText);\n  }\n}\nxhr.send(data);\n```\n\n文件名 filename 可以包含相对路径。比如：`upload?name=md/xxx.md`。则上传至 `md` 目录下。\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanxi%2Fhttp-file-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhanxi%2Fhttp-file-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanxi%2Fhttp-file-server/lists"}