{"id":19167506,"url":"https://github.com/tkdeng/webserver","last_synced_at":"2026-06-11T23:31:24.482Z","repository":{"id":261440786,"uuid":"884321185","full_name":"tkdeng/webserver","owner":"tkdeng","description":null,"archived":false,"fork":false,"pushed_at":"2024-11-06T14:49:04.000Z","size":665,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-22T23:26:35.579Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/tkdeng.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-06T14:42:27.000Z","updated_at":"2024-11-06T14:49:08.000Z","dependencies_parsed_at":"2024-11-06T15:49:54.874Z","dependency_job_id":null,"html_url":"https://github.com/tkdeng/webserver","commit_stats":null,"previous_names":["tkdeng/webserver"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tkdeng/webserver","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkdeng%2Fwebserver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkdeng%2Fwebserver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkdeng%2Fwebserver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkdeng%2Fwebserver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tkdeng","download_url":"https://codeload.github.com/tkdeng/webserver/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkdeng%2Fwebserver/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34222709,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-11T02:00:06.485Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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-09T09:37:55.771Z","updated_at":"2026-06-11T23:31:24.466Z","avatar_url":"https://github.com/tkdeng.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Web Server\n\n[\u003cimg src=\"./assets/icon.png\" alt=\"icon\" height=\"100\"/\u003e](./assets/icon.png)\n\nA Web Server Written In... Any Programming Language?\n\nDevelop a website with your favorite programming language.\nCurrently Supported Languages: C, Go, Scala.\n\nThis module runs a server with a golang base for handling http.\nTemplates are rendered in [htmlc](https://github.com/tkdeng/htmlc) which compiles to elixir.\n\n\u003e Notice: This Project Is Still In Beta.\n\n## Installation\n\n```shell\ngo get github.com/tkdeng/webserver\n```\n\n## Usage\n\n```go\nfunc main(){\n  // create new server\n  app, err := webserver.New(\"./app\")\n  \n  // do normal gofiber stuff (optional)\n  app.Get(\"/\", func(c fiber.Ctx) error {\n    return c.SendString(\"Hello, World!\")\n  })\n\n  app.Get(\"/\", func(c fiber.Ctx) error {\n    // note: c.Render is not used\n    // you can use a secondary template with gofiber\n    return webserver.Render(c, \"index\", htmlc.Map{\"args\": 1}, \"layout\")\n  })\n\n  // listen with openssl (default port: [http: 8080, ssl: 8443])\n  err = app.Listen()\n}\n```\n\n## Inside App Directory\n\n### config.yml\n\n```yaml\ntitle: \"Web Server\"\napp_title: \"WebServer\"\ndesc: \"A Web Server.\"\n\npublic_uri: \"/public/\"\n\nport_http: 8080\nport_ssl: 8443\n\norigins: [\n  \"localhost\",\n  \"example.com\",\n]\n\nproxies: [\n  \"127.0.0.1\",\n  \"192.168.0.1\",\n]\n\nDebugMode: no\n```\n\n### templates\n\nTemplates are compiled by the [htmlc](https://github.com/tkdeng/htmlc) module.\n\n### routes\n\nRoute files laid out in a nextjs like format.\nThese files can be written in a variety of different programming languages.\n\nPrint `@PAGE:\u003cname\u003e;`, `@LAYOUT:\u003cname\u003e;`, and `@ARGS:\u003cjson|base64\u003e;` to specify what page to render.\n\nHere is an example in C.\n\n```c\n#include \u003cstdio.h\u003e\n\nint main(){\n  printf(\"@PAGE:%s;\\n\", \"index\");\n  printf(\"@ARGS:%s;\\n\", \"{\\\"args\\\": 1}\");\n  printf(\"@LAYOUT:%s;\\n\", \"layout\");\n\n  return 0;\n}\n```\n\nYAML and JSON can also be used for simpler templates.\n\n```yaml\npage: index\nlayout: layout\nargs: {\n  title: \"Hello, Yaml!\",\n}\n```\n\nIn Scala, the file name represents a base route, and an object represents a sub path.\nFor example, if the file is named `test.scala`.\n\n```scala\nobject index { // `/test`\n  def main(args: Array[String]) = {\n    println(\"Hello, Scala!\")\n  }\n}\n\nobject about { // `/test/about`\n  def main(args: Array[String]) = {\n    println(\"About, Scala!\")\n  }\n}\n```\n\nWe can also name a directory with a languages extension, to have the folder compiled as a single file.\n\nFor example, in go we can name out directory `about.go/`.\nThen we can write our go module inside this directory.\n\nIn this example, `main.go` will be compiled with it's `go.mod` file, and any other files or subdirectories.\n\n```go\npackage main\n\nimport \"fmt\"\n\nfunc main() {\n  fmt.Println(\"Hello, Golang!\")\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftkdeng%2Fwebserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftkdeng%2Fwebserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftkdeng%2Fwebserver/lists"}