Skip to content

Latest commit

 

History

History
67 lines (46 loc) · 1.48 KB

README.md

File metadata and controls

67 lines (46 loc) · 1.48 KB
title keywords description
File Server
file server
static files
Serving static files.

File Server Example

Github StackBlitz

This project demonstrates how to set up a simple file server in a Go application using the Fiber framework.

Prerequisites

Ensure you have the following installed:

Setup

  1. Clone the repository:

    git clone https://github.com/gofiber/recipes.git
    cd recipes/file-server
  2. Install dependencies:

    go get

Running the Application

  1. Start the application:

    go run main.go
  2. Access the file server at http://localhost:3000.

Example

Here is an example main.go file for the Fiber application serving static files:

package main

import (
    "log"
    "github.com/gofiber/fiber/v2"
)

func main() {
    app := fiber.New()

    // Serve static files from the "public" directory
    app.Static("/", "./public")

    log.Fatal(app.Listen(":3000"))
}

References