From 666aab275c4002334295943ad58a7c310cb7519b Mon Sep 17 00:00:00 2001 From: rasmus Date: Fri, 24 Jan 2025 18:49:27 +0100 Subject: [PATCH] Fix not reading file correctly --- app/main.f90 | 4 ++-- src/FileReader.f90 | 10 ++++------ src/WebServer.f90 | 5 +++++ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/main.f90 b/app/main.f90 index db5aae1..66422b0 100644 --- a/app/main.f90 +++ b/app/main.f90 @@ -1,5 +1,5 @@ program main - use WebServer, only: get_progress + !use WebServer, only: get_progress use FileReader, only: read_file use Greeter, only: say_hello @@ -8,6 +8,6 @@ program main character, allocatable :: Data call say_hello() - call get_progress() + !call get_progress() call read_file("/home/skingging/Documents/Projects/Fortran/Web-Server-In-Fortran/html/index.html", Data) end program main diff --git a/src/FileReader.f90 b/src/FileReader.f90 index f8c2415..6ceff8a 100644 --- a/src/FileReader.f90 +++ b/src/FileReader.f90 @@ -1,5 +1,5 @@ module FileReader - !implicit none + implicit none public :: read_file contains @@ -10,8 +10,8 @@ module FileReader logical :: res character (len=*), intent (in) :: FileName character (len=*), allocatable, intent (out) :: Data - character(len=:), allocatable :: TempData - character(len=256) :: LineBuffer + character (len=:), allocatable :: TempData + character (len=256) :: LineBuffer inquire( file=trim(FileName), exist=res ) @@ -26,10 +26,8 @@ module FileReader allocate(character(len=0) :: TempData) ! Start with an empty string - read(io, *, iostat=iostat) - do - read(io, *, IOSTAT=iostat) LineBuffer + read(io, '(A)', IOSTAT=iostat) LineBuffer if (iostat /= 0) exit ! Exit loop on end-of-file or error ! Append the current line to TempData. CHAR(10) is a newline diff --git a/src/WebServer.f90 b/src/WebServer.f90 index 2c27028..de95b42 100644 --- a/src/WebServer.f90 +++ b/src/WebServer.f90 @@ -7,6 +7,11 @@ module WebServer public :: get_progress contains + + + ! https://github.com/modern-fortran/tcp-client-server/blob/master/server.f90 + + subroutine get_progress ! Send a GET request to retrieve JSON data response = request(url='https://proxy.rbwr.dk/progress')