Skip to content

Commit

Permalink
Handle html file types
Browse files Browse the repository at this point in the history
  • Loading branch information
sansyrox committed Feb 28, 2022
1 parent ef5e068 commit 5c7f7bc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 5 additions & 2 deletions robyn/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ def static_file(file_path):
"""

return {
"response_type": "static_file",
"file_path": file_path
"type": "static_file",
"file_path": file_path,
# this is a hack for now
"body": "",
"status_code": 200,
}


Expand Down
10 changes: 9 additions & 1 deletion src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,16 @@ async fn execute_http_function(
let res = Python::with_gil(|py| -> PyResult<HashMap<String, String>> {
println!("This is the result of the code {:?}", output);

let res: HashMap<String, String> =
let mut res: HashMap<String, String> =
output.into_ref(py).downcast::<PyDict>()?.extract()?;

let response_type = res.get("type").unwrap();

if response_type == "static_file" {
let file_path = res.get("file_path").unwrap();
let contents = read_file(file_path);
res.insert("body".to_owned(), contents.to_owned());
}
Ok(res)
})?;

Expand Down

0 comments on commit 5c7f7bc

Please sign in to comment.