diff --git a/.gitignore b/.gitignore index 45c4f1b..5209867 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,4 @@ *.out *.app +build/ diff --git a/app/main.f90 b/app/main.f90 index 983603a..4f5a644 100644 --- a/app/main.f90 +++ b/app/main.f90 @@ -1,6 +1,9 @@ program main - use WebServer, only: say_hello + use WebServer, only: get_progress + use Greeter, only: say_hello + implicit none call say_hello() + call get_progress() end program main diff --git a/fpm.toml b/fpm.toml index 1cd25ac..438a20a 100644 --- a/fpm.toml +++ b/fpm.toml @@ -15,4 +15,6 @@ library = false implicit-typing = false implicit-external = false source-form = "free" - +[dependencies] +http = { git = "https://github.com/fortran-lang/http-client.git" } +stdlib = "*" diff --git a/src/Greeter.f90 b/src/Greeter.f90 new file mode 100644 index 0000000..84a9e26 --- /dev/null +++ b/src/Greeter.f90 @@ -0,0 +1,10 @@ +module Greeter + implicit none + private + + public :: say_hello + contains + subroutine say_hello + print *, "Hello, WebServer!" + end subroutine say_hello +end module Greeter \ No newline at end of file diff --git a/src/WebServer.f90 b/src/WebServer.f90 index f7deead..2c27028 100644 --- a/src/WebServer.f90 +++ b/src/WebServer.f90 @@ -1,10 +1,25 @@ module WebServer - implicit none - private + use http, only : response_type, request + implicit none + type(response_type) :: response - public :: say_hello -contains - subroutine say_hello - print *, "Hello, WebServer!" - end subroutine say_hello -end module WebServer + private + + public :: get_progress + contains + subroutine get_progress + ! Send a GET request to retrieve JSON data + response = request(url='https://proxy.rbwr.dk/progress') + + ! Check if the request was successful + if (.not. response%ok) then + print *, 'Error message:', response%err_msg + else + ! Print the response details + print *, 'Response Code :', response%status_code + print *, 'Response Length :', response%content_length + print *, 'Response Method :', response%method + print *, 'Response Content :', response%content + end if + end subroutine get_progress +end module WebServer \ No newline at end of file