diff options
Diffstat (limited to 'captain/web.f90')
-rw-r--r-- | captain/web.f90 | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/captain/web.f90 b/captain/web.f90 index 57f57f9..dab017a 100644 --- a/captain/web.f90 +++ b/captain/web.f90 @@ -288,7 +288,7 @@ contains end if res = trim(res)//new_line(' ')//"<h2>Management</h2>"// & - new_line(' ')//'<form action="players/add.html" method="post"><label for="name">Name:</label>'// & + new_line(' ')//'<form action="players/add.html" method="POST"><label for="name">Name:</label>'// & '<input name="name" id="name" /><input type="submit" value="Add"/></form>' end function generate_players_html @@ -644,12 +644,12 @@ contains end function request_templated function handle_post(req) result(resp) + use captain_db, only: add_player_db use page_template - use config, only: template_filepath, project + use config, only: template_filepath use logging use server_response, only:request, response - use http, only: HTTP_CODE_SUCCESS, HTTP_CODE_NOTFOUND - use request_utils, only: get_job_page_title, handle_instruction_command + use http, only: HTTP_CODE_FAILURE, HTTP_CODE_SUCCESS use http_post_utilities use query_utilities, only: query implicit none @@ -664,6 +664,8 @@ contains character(64)::category, second posted = read_post_contents() + call write_log("Post Contents: "//posted%full, LOG_DEBUG) + if(posted%component_count() > 0) then ! We will immediately redirect after the command is handled @@ -674,13 +676,15 @@ contains call req%path_component(1, category) if(trim(category) == "players") then call req%path_component(2, second) + call write_log("Handling command for players: "//trim(second), LOG_INFO) ! Add a player if(trim(second) == "add.html") then + call add_player_db(posted%get_value("name")) call page%assign('destination', 'players.html') - + end if end if @@ -693,12 +697,13 @@ contains resp%temporary_file = .true. resp%body_filename => page%output_filename resp%body_mimetype = "text/html" + resp%code = HTTP_CODE_SUCCESS call posted%destroy() else - resp%code = 500 + resp%code = HTTP_CODE_FAILURE end if @@ -726,6 +731,7 @@ contains resp = request_static(req) else if(req%is_post()) then + call write_log("POST operation", LOG_INFO) resp = handle_post(req) else |