2020-11-03 19:09:17 +01:00
|
|
|
;****************************
|
|
|
|
;*
|
|
|
|
;* Lihaso Web Server
|
|
|
|
;*
|
2021-05-22 12:09:31 +02:00
|
|
|
;* HTTP/HTTPS example extended Server
|
2021-05-21 07:45:23 +02:00
|
|
|
;*
|
2023-03-29 10:47:34 +02:00
|
|
|
;* (c)2015 - 2023 by Linder Hard- und Software
|
2020-11-03 19:09:17 +01:00
|
|
|
;*
|
|
|
|
;*
|
|
|
|
|
|
|
|
EnableExplicit
|
2023-03-29 10:47:34 +02:00
|
|
|
OpenConsole("server_example Console")
|
|
|
|
PrintN("Server_Sample and tests")
|
2020-11-03 19:09:17 +01:00
|
|
|
;*
|
2021-05-22 12:09:31 +02:00
|
|
|
;* Includes:
|
2020-11-03 19:09:17 +01:00
|
|
|
;*
|
|
|
|
|
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.
|
2023-03-29 10:47:34 +02:00
|
|
|
XIncludeFile "lhs_lib/SYS/lhs_sys_debug_wrapper.pbi"
|
2020-11-03 19:09:17 +01:00
|
|
|
XIncludeFile "lweb_header.pbi"
|
|
|
|
XIncludeFile "lweb.pbi"
|
|
|
|
|
2021-05-22 12:09:31 +02:00
|
|
|
;*
|
|
|
|
;* Variable declaration:
|
|
|
|
;*
|
|
|
|
|
2020-11-03 19:09:17 +01:00
|
|
|
Define counter, v_lweb_srv_stop
|
2023-03-29 10:47:34 +02:00
|
|
|
Global Accesslog.s, Errorlog.s, Cachelog.s, DebugLog.s, Debuggings.s
|
2021-05-21 07:45:23 +02:00
|
|
|
|
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")
|
2023-03-29 10:47:34 +02:00
|
|
|
lhs_log_ext::SetLogFile(DebugLog, "lweb_debug.log")
|
2023-03-27 17:38:13 +02:00
|
|
|
lhs_log_ext::Init(DebugLog)
|
2023-03-29 10:47:34 +02:00
|
|
|
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)
|
2022-02-17 13:23:42 +01:00
|
|
|
|
2023-03-29 10:47:34 +02:00
|
|
|
Debuggings = lhs_web::get_config(lhs_web::#conf_Debug_logUUID)
|
|
|
|
Debug Debuggings
|
2020-11-03 19:09:17 +01:00
|
|
|
;*
|
|
|
|
;* includes
|
|
|
|
;*
|
|
|
|
|
2023-03-27 17:38:13 +02:00
|
|
|
XIncludeFile "server_example_function.pbi"
|
2020-11-08 23:14:35 +01:00
|
|
|
|
2023-03-29 10:47:34 +02:00
|
|
|
PrintN("Read Configuration:")
|
2020-11-03 19:09:17 +01:00
|
|
|
;*
|
2023-03-29 10:47:34 +02:00
|
|
|
;* Read Configuration http & https Server
|
2020-11-03 19:09:17 +01:00
|
|
|
;*
|
2023-03-30 09:55:55 +02:00
|
|
|
If lhs_web::server_initial("file:cfg/server_config.xml")
|
2023-03-29 10:47:34 +02:00
|
|
|
ldl::Logging("config succesfully loaded.")
|
2020-11-03 19:09:17 +01:00
|
|
|
Else
|
2023-03-29 10:47:34 +02:00
|
|
|
ldl::Logging("config load failed.")
|
2020-11-03 19:09:17 +01:00
|
|
|
End
|
|
|
|
EndIf
|
|
|
|
|
2023-03-29 10:47:34 +02:00
|
|
|
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")
|
|
|
|
If lhs_web::server_start()
|
|
|
|
ldl::Logging("Server started")
|
|
|
|
Else
|
|
|
|
ldl::Logging("Start failed.")
|
|
|
|
End
|
|
|
|
EndIf
|
|
|
|
|
2020-11-03 19:09:17 +01:00
|
|
|
counter = 0
|
2023-03-29 10:47:34 +02:00
|
|
|
PrintN("Server_Sample started.")
|
2020-11-03 19:09:17 +01:00
|
|
|
PrintN("Press Enter to Exit")
|
|
|
|
Input()
|
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")
|
|
|
|
|
2020-11-03 19:09:17 +01:00
|
|
|
End
|