lweb/server_example.pb

89 lines
2.4 KiB
Text
Raw Normal View History

;****************************
;*
;* Lihaso Web Server
;*
2021-05-22 12:09:31 +02:00
;* HTTP/HTTPS example extended Server
;*
2024-03-13 09:23:28 +01:00
;* (c)2015 - 2024 by Linder Hard- und Software
;*
;*
EnableExplicit
OpenConsole("server_example Console")
PrintN("Server_Sample and tests")
;*
2021-05-22 12:09:31 +02:00
;* Includes:
;*
2021-05-21 11:24:35 +02:00
XIncludeFile "lhs_lib/SYS/lhs_log_ext.pbi" ;User for Access Log, Error Access Log, Error Log and maybe more.
XIncludeFile "lhs_lib/SYS/lhs_sys_debug_wrapper.pbi"
XIncludeFile "lweb_header.pbi"
XIncludeFile "lweb.pbi"
2021-05-22 12:09:31 +02:00
;*
;* Variable declaration:
;*
Define counter, v_lweb_srv_stop
Global Accesslog.s, Errorlog.s, Cachelog.s, DebugLog.s, Debuggings.s
2021-05-22 12:09:31 +02:00
;*
;* Enable extended Logging:
;*
2023-03-27 17:38:13 +02:00
DebugLog = lhs_log_ext::Create("DebugLog")
lhs_log_ext::SetLogFile(DebugLog, "lweb_debug.log")
2023-03-27 17:38:13 +02:00
lhs_log_ext::Init(DebugLog)
ldl::Register(lhs_log_ext::@Out(), DebugLog, 1, DebugLog, ldl::#AdvancedLog)
ldl::SetDefault(DebugLog)
ldl::Logging("Start Debug Log registered with ldl at UUID:"+DebugLog)
2024-03-13 09:23:28 +01:00
ldl::Logging("-------------------------------------------------------------------------------------------------------------------------------")
ldl::Logging("Server initializing.")
ldl::Logging("-------------------------------------------------------------------------------------------------------------------------------")
Debuggings = lhs_web::get_config(lhs_web::#conf_Debug_logUUID)
Debug Debuggings
;*
;* includes
;*
2023-03-27 17:38:13 +02:00
XIncludeFile "server_example_function.pbi"
PrintN("Read Configuration:")
;*
;* Read Configuration http & https Server
;*
If lhs_web::server_initial("file:cfg/server_config.xml")
ldl::Logging("config succesfully loaded.")
Else
ldl::Logging("config load failed.")
End
EndIf
PrintN("HTTP an Port:"+lhs_web::server_get_config("ports_http"))
PrintN("HTTPS an Port:"+lhs_web::server_get_config("ports_https"))
PrintN("Configuration read done.")
;*
;* Start Server
;*
PrintN("Start the Server")
2024-03-13 09:23:28 +01:00
lhs_web::main_server(0)
If lhs_web::server_start()
ldl::Logging("Server started")
Else
ldl::Logging("Start failed.")
End
EndIf
counter = 0
PrintN("Server_Sample started.")
PrintN("Press Enter to Exit")
Input()
2024-03-13 09:23:28 +01:00
ldl::Logging("-------------------------------------------------------------------------------------------------------------------------------")
ldl::Logging("Server Stopped.")
ldl::Logging("-------------------------------------------------------------------------------------------------------------------------------")
2021-05-25 10:05:41 +02:00
lhs_log_ext::StopAllLogger()
2023-03-27 17:38:13 +02:00
lhs_web::server_stop()
2021-05-25 10:05:41 +02:00
PrintN("Finished")
End