Add working prototype for retrieving data
This commit is contained in:
parent
1bfccba59f
commit
f47f2e738f
1
.gitignore
vendored
1
.gitignore
vendored
@ -32,3 +32,4 @@
|
||||
*.out
|
||||
*.app
|
||||
|
||||
build/
|
||||
|
@ -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
|
||||
|
4
fpm.toml
4
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 = "*"
|
||||
|
10
src/Greeter.f90
Normal file
10
src/Greeter.f90
Normal file
@ -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
|
@ -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
|
||||
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
|
Loading…
Reference in New Issue
Block a user