-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from saviorand/feature/static-files-basic
Enable serving static files
- Loading branch information
Showing
16 changed files
with
271 additions
and
165 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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from lightbug_http.http import HTTPRequest, encode | ||
from lightbug_http.header import RequestHeader | ||
from lightbug_http.uri import URI | ||
from lightbug_http.sys.client import MojoClient | ||
|
||
fn test_request(inout client: MojoClient) raises -> None: | ||
var uri = URI("http://httpbin.org/status/404") | ||
var request = HTTPRequest(uri) | ||
var response = client.do(request) | ||
|
||
# print status code | ||
print("Response:", response.header.status_code()) | ||
|
||
# print raw headers | ||
# print("Headers:", response.header.headers()) | ||
|
||
# print parsed headers (only some are parsed for now) | ||
print("Content-Type:", String(response.header.content_type())) | ||
print("Content-Length", response.header.content_length()) | ||
print("Connection:", response.header.connection_close()) | ||
print("Server:", String(response.header.server())) | ||
|
||
# print body | ||
print(String(response.get_body())) | ||
|
||
|
||
fn main() raises -> None: | ||
var client = MojoClient() | ||
test_request(client) |
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,5 +1,4 @@ | ||
from lightbug_http import * | ||
from sys import is_defined | ||
|
||
fn main() raises: | ||
var server = SysServer() | ||
|
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
Oops, something went wrong.