{"id":20291777,"url":"https://github.com/samuelnovaes/easy-cgi","last_synced_at":"2025-03-04T05:11:44.921Z","repository":{"id":57218353,"uuid":"113782918","full_name":"samuelnovaes/easy-cgi","owner":"samuelnovaes","description":"Easily create a CGI server","archived":false,"fork":false,"pushed_at":"2017-12-10T23:05:20.000Z","size":21,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-15T06:47:57.646Z","etag":null,"topics":["cgi","easy","http","server","web"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/samuelnovaes.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":"2017-12-10T20:56:20.000Z","updated_at":"2023-04-11T21:44:59.000Z","dependencies_parsed_at":"2022-08-28T21:01:54.302Z","dependency_job_id":null,"html_url":"https://github.com/samuelnovaes/easy-cgi","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelnovaes%2Feasy-cgi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelnovaes%2Feasy-cgi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelnovaes%2Feasy-cgi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelnovaes%2Feasy-cgi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samuelnovaes","download_url":"https://codeload.github.com/samuelnovaes/easy-cgi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241787487,"owners_count":20020101,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["cgi","easy","http","server","web"],"created_at":"2024-11-14T15:13:52.334Z","updated_at":"2025-03-04T05:11:44.904Z","avatar_url":"https://github.com/samuelnovaes.png","language":"JavaScript","readme":"# Easily create a CGI server\n\n[![NPM](https://nodei.co/npm/easy-cgi.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/easy-cgi/)\n\n# Installation\n\n- Install [Node.js](https://nodejs.org)\n- Install easy-cgi\n\n```\nnpm install -g easy-cgi\n```\n\n# Example (Using Bash)\n\nCreate a directory for your app whith your CGI executable files.\n\nApp directory\n\n```\napp\n└---hello.sh\n```\n\napp/hello.sh\n\n```bash\n#!/bin/sh\n\n# Headers are written first. The special \"Status\"\n# header indicates the response status code\necho \"Status: 200\"\necho \"Content-Type: text/plain\"\necho\n\n# Followed by a response body\necho \"Hello World!\"\n```\n\n\nGive execute permissions to the file\n```bash\nchmod +x hello.sh\n```\n\nThen start your CGI server\n\n```bash\ncgi\n```\n\n\nAccess the address http://localhost:8080/hello in the browser\n\n# Routing\n\nThe routes are created automatically by file name\n\nExample:\n\n- For the `app/hello.sh` file, the route is `/hello`\n- For the `app/foo/bar.sh` file, the route is `/foo/bar`\n- For the `app/index.sh` file, the route is `/`\n- For the `app/foo/index.sh` file, the route is `/foo`\n\n\u003e If you create a `app/src` directory, it will be ignored\n\n### Dynamic routes\n\nDynamic routes are created adding underscore in file name or directory\n\nExample:\n\n- For the `app/users/_id.sh` file, the route is `/users/\u003cid\u003e`\n- For the `app/_foo/bar.sh` file, the route is `/\u003cfoo\u003e/bar`\n\n# Get request values\n\nYou can access the request values ​​through the REQUEST environment variable in JSON format\n\nThe REQUEST environment variable looks like\n\n```json\n{\n\t\"body\": {},\n\t\"params\": {},\n\t\"query\": {},\n\t\"headers\": {},\n\t\"files\": {}\n}\n```\n\n\u003e No sessions are supported yet\n\n# Static files\n\nTo serve static files, create a `static` directory\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuelnovaes%2Feasy-cgi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamuelnovaes%2Feasy-cgi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuelnovaes%2Feasy-cgi/lists"}