aboutsummaryrefslogtreecommitdiff
path: root/captain/web.f90
diff options
context:
space:
mode:
Diffstat (limited to 'captain/web.f90')
-rw-r--r--captain/web.f9045
1 files changed, 45 insertions, 0 deletions
diff --git a/captain/web.f90 b/captain/web.f90
index 0f741d8..57f57f9 100644
--- a/captain/web.f90
+++ b/captain/web.f90
@@ -650,12 +650,57 @@ contains
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_post_utilities
+ use query_utilities, only: query
implicit none
type(request), intent(in)::req
type(response)::resp
+ type(query)::posted
+
+ character(1024)::template_file
+ type(template)::page
+
+ character(64)::category, second
+
+ posted = read_post_contents()
+ if(posted%component_count() > 0) then
+
+ ! We will immediately redirect after the command is handled
+ call template_filepath("redirect.html", template_file)
+ call page%init(trim(template_file))
+
+ ! Handle based on category
+ call req%path_component(1, category)
+ if(trim(category) == "players") then
+ call req%path_component(2, second)
+
+ ! 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
+
+ ! Handle the template
+ call page%assign('base_url', req%server)
+ call page%render()
+ call write_log("Finalizing response", LOG_INFO)
+ resp%temporary_file = .true.
+ resp%body_filename => page%output_filename
+ resp%body_mimetype = "text/html"
+
+ call posted%destroy()
+
+ else
+ resp%code = 500
+
+ end if
end function handle_post