Add a Simple Webserver configurable (HTTP&HTTPS)
This commit is contained in:
		
							parent
							
								
									5a3e18a541
								
							
						
					
					
						commit
						060e663aaa
					
				
					 2 changed files with 81 additions and 0 deletions
				
			
		
							
								
								
									
										16
									
								
								lhttpd.ini
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								lhttpd.ini
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,16 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[lhttpd]
 | 
				
			||||||
 | 
					HTTP_Port=8081
 | 
				
			||||||
 | 
					HTTP_Binding=0.0.0.0
 | 
				
			||||||
 | 
					HTTPS_CA=/home/renlin/dev/libressl/sample/test_ca.pem
 | 
				
			||||||
 | 
					HTTPS_Cert=/home/renlin/dev/libressl/sample/test_server_cert.pem
 | 
				
			||||||
 | 
					HTTPS_Key=/home/renlin/dev/libressl/sample/test_server_key.pem
 | 
				
			||||||
 | 
					HTTPS_Key_Pass=test-server-pass
 | 
				
			||||||
 | 
					HTTPS_Port=8444
 | 
				
			||||||
 | 
					HTTPS_Binding=127.0.0.1
 | 
				
			||||||
 | 
					HTTPS_enable=1
 | 
				
			||||||
 | 
					Defaultfile=/index.html
 | 
				
			||||||
 | 
					Basedirectory=/home/renlin/testweb/
 | 
				
			||||||
 | 
					Error400_Handling=integrated
 | 
				
			||||||
 | 
					MaxClients=100
 | 
				
			||||||
 | 
					Filememorycache=0
 | 
				
			||||||
							
								
								
									
										65
									
								
								lhttpd.pb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								lhttpd.pb
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,65 @@
 | 
				
			||||||
 | 
					;****************************
 | 
				
			||||||
 | 
					;*
 | 
				
			||||||
 | 
					;* Lihaso Web Server (lhttpd)
 | 
				
			||||||
 | 
					;*
 | 
				
			||||||
 | 
					;* (c)2020 by Linder Hard- und Software
 | 
				
			||||||
 | 
					;*
 | 
				
			||||||
 | 
					;* V0.5
 | 
				
			||||||
 | 
					;* - Simple webserver for HTTP & HTTPS
 | 
				
			||||||
 | 
					;*
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					EnableExplicit
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					;*
 | 
				
			||||||
 | 
					;* Variable Declaration.
 | 
				
			||||||
 | 
					;*
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					XIncludeFile "lweb_header.pbi"
 | 
				
			||||||
 | 
					XIncludeFile "lweb.pbi"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					OpenConsole("Test")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					If OpenPreferences("lhttpd.ini", #PB_Preference_GroupSeparator)
 | 
				
			||||||
 | 
					  If PreferenceGroup("lhttpd")
 | 
				
			||||||
 | 
					    lhs_web::set_config(lhs_web::#conf_port, ReadPreferenceString("HTTP_Port","8081"))
 | 
				
			||||||
 | 
					    lhs_web::set_config(lhs_web::#conf_binding, ReadPreferenceString("HTTP_Binding","0.0.0.0"))
 | 
				
			||||||
 | 
					    lhs_web::set_config(lhs_web::#conf_HTTPS_CA, ReadPreferenceString("HTTPS_CA","/home/renlin/dev/libressl/sample/test_ca.pem"))
 | 
				
			||||||
 | 
					    lhs_web::set_config(lhs_web::#conf_HTTPS_Cert, ReadPreferenceString("HTTPS_Cert","/home/renlin/dev/libressl/sample/test_server_cert.pem"))
 | 
				
			||||||
 | 
					    lhs_web::set_config(lhs_web::#conf_HTTPS_Key, ReadPreferenceString("HTTPS_Key","/home/renlin/dev/libressl/sample/test_server_key.pem"))
 | 
				
			||||||
 | 
					    lhs_web::set_config(lhs_web::#conf_HTTPS_Key_Pass, ReadPreferenceString("HTTPS_Key_Pass","test-server-pass"))
 | 
				
			||||||
 | 
					    lhs_web::set_config(lhs_web::#conf_HTTPS_Port, ReadPreferenceString("HTTPS_Port","8444"))
 | 
				
			||||||
 | 
					    lhs_web::set_config(lhs_web::#conf_HTTPS_Binding, ReadPreferenceString("HTTPS_Binding","127.0.0.1"))
 | 
				
			||||||
 | 
					    lhs_web::set_config(lhs_web::#conf_HTTPS_Enable, ReadPreferenceString("HTTPS_enable","0"))
 | 
				
			||||||
 | 
					    lhs_web::set_config(lhs_web::#conf_defaultfile, ReadPreferenceString("Defaultfile","/index.html"))
 | 
				
			||||||
 | 
					    lhs_web::set_config(lhs_web::#conf_basedir, ReadPreferenceString("Basedirectory","/home/renlin/testweb/"))
 | 
				
			||||||
 | 
					    lhs_web::set_config(lhs_web::#conf_error400, ReadPreferenceString("Error400_Handling","integrated"))
 | 
				
			||||||
 | 
					    lhs_web::set_config(lhs_web::#conf_max_clients, ReadPreferenceString("MaxClients","100"))
 | 
				
			||||||
 | 
					    lhs_web::set_config(lhs_web::#conf_cache_enable, ReadPreferenceString("Filememorycache","0"))
 | 
				
			||||||
 | 
					    ClosePreferences()
 | 
				
			||||||
 | 
					  Else
 | 
				
			||||||
 | 
					    PrintN("No correct config file -> End")
 | 
				
			||||||
 | 
					    End
 | 
				
			||||||
 | 
					  EndIf
 | 
				
			||||||
 | 
					Else
 | 
				
			||||||
 | 
					  PrintN("Could not open config file.")
 | 
				
			||||||
 | 
					EndIf
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					;*
 | 
				
			||||||
 | 
					;* includes
 | 
				
			||||||
 | 
					;*
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					If lhs_web::start_server()
 | 
				
			||||||
 | 
					  Debug "Server gestartet" + lhs_web::get_config(lhs_web::#conf_port)
 | 
				
			||||||
 | 
					Else
 | 
				
			||||||
 | 
					  Debug "Fehlgeschlagen"
 | 
				
			||||||
 | 
					  End
 | 
				
			||||||
 | 
					EndIf
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					PrintN("Webserver")
 | 
				
			||||||
 | 
					PrintN("HTTP an Port:"+lhs_web::get_config(lhs_web::#conf_port))
 | 
				
			||||||
 | 
					PrintN("HTTPS an Port:"+lhs_web::get_config(lhs_web::#conf_HTTPS_Port))
 | 
				
			||||||
 | 
					PrintN("Press Enter to Exit")
 | 
				
			||||||
 | 
					Input()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					End
 | 
				
			||||||
		Loading…
	
		Reference in a new issue