This is a simple web application written in Go that demonstrates basic file handling, HTTP request handling.
- View a page
- Edit a page
- Save a page
- Go installed on your system. You can download it from golang.org.
- Clone the repository:
git clone https://github.com/RoshanShrestha123/wiki-server
- Navigate into the project directory:
cd wiki-server
- Run the application:
go run main.go
- Open your web browser and navigate to
http://localhost:8000
.
/view/{title}
: View a page with the given title./edit/{title}
: Edit a page with the given title./save/{title}
: Save a page with the given title and body./
: Root endpoint, displays a simple greeting.
- Navigate to
http://localhost:8000/view/TestPage
to view a page namedTestPage
. - Navigate to
http://localhost:8000/edit/TestPage
to edit theTestPage
. - Submit the form to save changes to
TestPage
.
Page
struct: Represents a web page with a title and body.save
method: Saves the page content to a text file.loadPage
function: Loads a page from a text file.viewHandler
function: Handles viewing a page.saveHandler
function: Handles saving a page.editHandler
function: Handles editing a page.handler
function: Handles the root endpoint.