-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9a38ab9
commit 46b2973
Showing
2 changed files
with
21 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,31 @@ | ||
import http | ||
|
||
let port = "3000" | ||
let dir = "/var/www/html" | ||
let port = "3000"; | ||
let dir = "/var/www/html"; | ||
|
||
// Scenario 1: Using the default message and no directory listing | ||
http.fileServer(port, dir) | ||
http.fileServer(port, dir); | ||
|
||
// Scenario 2: Starting a file server with a custom message | ||
http.fileServer( | ||
port, | ||
dir, | ||
"My custom Vint server is running on port 3000!" | ||
) | ||
); | ||
|
||
// Scenario 3: Starting a file server with directory listing enabled (default message) | ||
http.fileServer( | ||
port, | ||
dir, | ||
null, // No custom message, use the default | ||
true // Enable directory listing | ||
) | ||
dir | ||
); | ||
|
||
// Scenario 4: Starting a file server with a custom message and directory listing enabled | ||
http.fileServer( | ||
port, | ||
dir, | ||
"Directory listing is now enabled! Check it out!", | ||
true | ||
) | ||
|
||
// Scenario 5: Starting a file server with a custom message and directory listing disabled | ||
http.fileServer( | ||
port, | ||
dir, | ||
"No directory listing. Just serving static files.", | ||
false | ||
) | ||
"Directory listing is now enabled! Check it out!" | ||
); | ||
|
||
// Scenario 6: Invalid usage (e.g., wrong arguments) - this should return an error | ||
http.fileServer(3000, dir) // Port must be a string | ||
http.fileServer(port, 123) // Directory must be a string | ||
http.fileServer(port, dir, 404) // Message must be a string | ||
http.fileServer(port, dir, "Message", "true") // enableListing must be a boolean | ||
// Scenario 5: Invalid usage (e.g., wrong arguments) - this should return an error | ||
http.fileServer(3000, dir); // Port must be a string | ||
http.fileServer(port, 123); // Directory must be a string | ||
http.fileServer(port, dir, 404); // Message must be a string | ||
http.fileServer(port, dir, "Message", "true"); // enableListing must be a boolean |