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
|
*.out
|
||||||
*.app
|
*.app
|
||||||
|
|
||||||
|
build/
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
program main
|
program main
|
||||||
use WebServer, only: say_hello
|
use WebServer, only: get_progress
|
||||||
|
use Greeter, only: say_hello
|
||||||
|
|
||||||
implicit none
|
implicit none
|
||||||
|
|
||||||
call say_hello()
|
call say_hello()
|
||||||
|
call get_progress()
|
||||||
end program main
|
end program main
|
||||||
|
4
fpm.toml
4
fpm.toml
@ -15,4 +15,6 @@ library = false
|
|||||||
implicit-typing = false
|
implicit-typing = false
|
||||||
implicit-external = false
|
implicit-external = false
|
||||||
source-form = "free"
|
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
|
module WebServer
|
||||||
implicit none
|
use http, only : response_type, request
|
||||||
private
|
implicit none
|
||||||
|
type(response_type) :: response
|
||||||
|
|
||||||
public :: say_hello
|
private
|
||||||
contains
|
|
||||||
subroutine say_hello
|
public :: get_progress
|
||||||
print *, "Hello, WebServer!"
|
contains
|
||||||
end subroutine say_hello
|
subroutine get_progress
|
||||||
end module WebServer
|
! 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