Individuell bearbeitete Subdirs
- Post - Get - Fixes in diversen bereichen... - Test Routinen erweitert - uvm.
This commit is contained in:
parent
47eb089154
commit
c6584ccb8f
3 changed files with 731 additions and 300 deletions
|
@ -31,12 +31,37 @@ DeclareModule lhs_web
|
||||||
#conf_cache_enable
|
#conf_cache_enable
|
||||||
EndEnumeration
|
EndEnumeration
|
||||||
|
|
||||||
Enumeration cli_handler
|
Enumeration cli_handler 1
|
||||||
#handler_only ;Reagiert nur auf die Url (Bsp. /rest/v1/test aber nicht auf /rest/v1/test/sub)
|
#handler_only ;Reagiert nur auf die Url (Bsp. /rest/v1/test aber nicht auf /rest/v1/test/sub)
|
||||||
#handler_sub ;Reagiert auf eine ganze Url die begint. (Bsp. /rest/v1/test sowie auch auf /rest/v1/test/sub)
|
#handler_sub ;Reagiert auf eine ganze Url die begint. (Bsp. /rest/v1/test sowie auch auf /rest/v1/test/sub)
|
||||||
#handler_type ;Reagiert auf datentypen (zb. *.php)
|
#handler_type ;Reagiert auf datentypen (zb. *.php = "php")
|
||||||
EndEnumeration
|
EndEnumeration
|
||||||
|
|
||||||
|
Enumeration e_handler_prototype 1
|
||||||
|
#handler_proto_universal
|
||||||
|
#handler_proto_post
|
||||||
|
#handler_proto_get
|
||||||
|
EndEnumeration
|
||||||
|
|
||||||
|
Enumeration cli_handler_app 1
|
||||||
|
#app_handler_map_string ;.s App(Requested.s, Map HandlerMap.s())
|
||||||
|
#app_handler_json ;.s App(Requested.s, JSONString.s)
|
||||||
|
#app_handler_string ;.s App(Requested.s, String.s)
|
||||||
|
#app_handler_ressource ;.s App(Requested.s)
|
||||||
|
EndEnumeration
|
||||||
|
|
||||||
|
#response_string = "response_string"
|
||||||
|
#response_Memory = "response_memory"
|
||||||
|
|
||||||
|
|
||||||
|
;cli_handler_app Return:
|
||||||
|
;Map.s() to JSONString
|
||||||
|
#cha_R_ResponseType = "ResponseType" ;Element ResponseType :Mimetype
|
||||||
|
#cha_R_ResponseContentType = "ResponseContentType" ;Element ResponseContentType :#response_string , #response_Memory
|
||||||
|
#cha_R_MemoryAdress = "MemoryAdress" ;Element MemoryAdress :Converted to String
|
||||||
|
#cha_R_MemorySize = "MemorySize" ;Element MemorySize :Converted to String
|
||||||
|
#cha_R_StringBase64 = "StringBase64" ;Element StringBase64 :Base64 Encoded String
|
||||||
|
#cha_R_http_head_status = "HeaderStatus" ;200 OK 300 Error 500 Server Error usw.
|
||||||
#error_string = "error"
|
#error_string = "error"
|
||||||
#http_head_method = "method"
|
#http_head_method = "method"
|
||||||
#http_head_request = "request"
|
#http_head_request = "request"
|
||||||
|
@ -50,13 +75,15 @@ DeclareModule lhs_web
|
||||||
#http_head_connection = "connection:"
|
#http_head_connection = "connection:"
|
||||||
#http_head_keep_alive = "keep-alive:"
|
#http_head_keep_alive = "keep-alive:"
|
||||||
|
|
||||||
|
#http_content_type_application_x_www_form_urlencoded = "application/x-www-form-urlencoded"
|
||||||
|
#http_content_type_multipart_form_data = "multipart/form-data"
|
||||||
|
|
||||||
Declare set_config(parameter.i=#conf_defaultfile, setting.s="index.html")
|
Declare set_config(parameter.i=#conf_defaultfile, setting.s="index.html")
|
||||||
Declare.s get_config(parameter.i=#conf_defaultfile)
|
Declare.s get_config(parameter.i=#conf_defaultfile)
|
||||||
Declare start_server()
|
Declare start_server()
|
||||||
;Declare.s register_client_handler(Route.s, Callback.i, Parameter.i = #handler_sub)
|
Declare.s register_client_handler(Route.s, Callback.i, AppPrototype.i = #handler_proto_get, RouteType.i = #handler_sub)
|
||||||
;Declare.s register_client_handler_JSON(Route.s, Callback.i, JSONString.s, Parameter.i = #handler_sub)
|
Declare.s mimetype(file.s)
|
||||||
|
Declare.s MapStringToJSONString(Map ConvertMap.s())
|
||||||
;Declare register_client_handler(Type.s)
|
|
||||||
Declare IsIPStringValid(Adress.s)
|
Declare IsIPStringValid(Adress.s)
|
||||||
|
|
||||||
EndDeclareModule
|
EndDeclareModule
|
|
@ -24,8 +24,8 @@ lhs_web::set_config(lhs_web::#conf_port, "8099")
|
||||||
;lhs_web::set_config(lhs_web::#conf_binding, "127.0.0.1")
|
;lhs_web::set_config(lhs_web::#conf_binding, "127.0.0.1")
|
||||||
lhs_web::set_config(lhs_web::#conf_binding, "0.0.0.0")
|
lhs_web::set_config(lhs_web::#conf_binding, "0.0.0.0")
|
||||||
|
|
||||||
lhs_web::set_config(lhs_web::#conf_defaultfile, "index.html")
|
lhs_web::set_config(lhs_web::#conf_defaultfile, "/index.html")
|
||||||
lhs_web::set_config(lhs_web::#conf_basedir, "/srv/www/htdocs/")
|
lhs_web::set_config(lhs_web::#conf_basedir, "/home/renlin/testweb/")
|
||||||
lhs_web::set_config(lhs_web::#conf_error400, "integrated")
|
lhs_web::set_config(lhs_web::#conf_error400, "integrated")
|
||||||
lhs_web::set_config(lhs_web::#conf_max_clients, "100")
|
lhs_web::set_config(lhs_web::#conf_max_clients, "100")
|
||||||
lhs_web::set_config(lhs_web::#conf_cache_enable, "0")
|
lhs_web::set_config(lhs_web::#conf_cache_enable, "0")
|
||||||
|
@ -33,7 +33,56 @@ lhs_web::set_config(lhs_web::#conf_cache_enable, "0")
|
||||||
;* includes
|
;* includes
|
||||||
;*
|
;*
|
||||||
|
|
||||||
|
Procedure.s Sample_Header(Map Header.s())
|
||||||
|
Define *Text
|
||||||
|
Define.s Encoded, ZumSenden, TBD
|
||||||
|
NewMap Response.s()
|
||||||
|
TBD="<div><div><h1>Header</h1></div><br/>"+#CRLF$
|
||||||
|
ResetMap(Header())
|
||||||
|
While NextMapElement(Header())
|
||||||
|
TBD = TBD+"<div>"+MapKey(Header())+" : "+Header()+" </div><br/>"+#CRLF$
|
||||||
|
Wend
|
||||||
|
|
||||||
|
*Text = UTF8("<!DOCTYPE html><html><header><title>Alle Client Headers</title></header><body>"+TBD+"</body></html>")
|
||||||
|
Encoded = Base64Encoder(*Text, MemorySize(*Text))
|
||||||
|
Debug "Encoded: " + Encoded
|
||||||
|
Response(lhs_web::#cha_R_ResponseContentType) = lhs_web::#response_string
|
||||||
|
Response(lhs_web::#cha_R_StringBase64) = Encoded
|
||||||
|
Response(lhs_web::#cha_R_ResponseType) = lhs_web::mimetype("html")
|
||||||
|
Response(lhs_web::#cha_R_http_head_status) = "200 OK"
|
||||||
|
ZumSenden = lhs_web::MapStringToJSONString(Response())
|
||||||
|
Debug "ZumSenden: " + ZumSenden
|
||||||
|
ProcedureReturn ZumSenden
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
|
Procedure.s Formular_Test(Map Header.s(), ContentData.s)
|
||||||
|
Define *Text
|
||||||
|
Define.s Encoded, ZumSenden, TBD
|
||||||
|
NewMap Response.s()
|
||||||
|
TBD="<div><div><h1>FormularPost</h1></div><br/>"+#CRLF$
|
||||||
|
ResetMap(Header())
|
||||||
|
While NextMapElement(Header())
|
||||||
|
TBD = TBD+"<div>"+MapKey(Header())+" : "+Header()+" </div><br/>"+#CRLF$
|
||||||
|
Wend
|
||||||
|
Debug "TBD:"+TBD
|
||||||
|
Debug "contentData:"+ContentData
|
||||||
|
*Text = UTF8("<!DOCTYPE html><html><header><title>Alle Client Headers</title></header><body>"+TBD+"<hr/><br/><h1>ConentJSON</h1><br/>"+ContentData+"</body></html>")
|
||||||
|
Debug "Unencoded:"+PeekS(*Text, -1 , #PB_UTF8)
|
||||||
|
Encoded = Base64Encoder(*Text, MemorySize(*Text))
|
||||||
|
Debug "Encoded: " + Encoded
|
||||||
|
Response(lhs_web::#cha_R_ResponseContentType) = lhs_web::#response_string
|
||||||
|
Response(lhs_web::#cha_R_StringBase64) = Encoded
|
||||||
|
Response(lhs_web::#cha_R_ResponseType) = lhs_web::mimetype("html")
|
||||||
|
Response(lhs_web::#cha_R_http_head_status) = "200 OK"
|
||||||
|
ZumSenden = lhs_web::MapStringToJSONString(Response())
|
||||||
|
Debug "ZumSenden: " + ZumSenden
|
||||||
|
ProcedureReturn ZumSenden
|
||||||
|
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
|
lhs_web::register_client_handler("/server/show_client_headers", @Sample_Header(),lhs_web::#handler_proto_get, lhs_web::#handler_sub)
|
||||||
|
|
||||||
|
lhs_web::register_client_handler("/post_test", @Formular_Test(),lhs_web::#handler_proto_post, lhs_web::#handler_sub)
|
||||||
|
|
||||||
;*
|
;*
|
||||||
;* Initialisierung Netzwerk
|
;* Initialisierung Netzwerk
|
||||||
|
@ -49,7 +98,7 @@ Else
|
||||||
EndIf
|
EndIf
|
||||||
|
|
||||||
If lhs_web::start_server()
|
If lhs_web::start_server()
|
||||||
Debug "Server gestartet"
|
Debug "Server gestartet" + lhs_web::get_config(lhs_web::#conf_port)
|
||||||
Else
|
Else
|
||||||
Debug "Fehlgeschlagen"
|
Debug "Fehlgeschlagen"
|
||||||
End
|
End
|
||||||
|
@ -57,6 +106,7 @@ EndIf
|
||||||
|
|
||||||
counter = 0
|
counter = 0
|
||||||
OpenConsole("Test")
|
OpenConsole("Test")
|
||||||
|
PrintN("Webserver an Port:"+lhs_web::get_config(lhs_web::#conf_port))
|
||||||
PrintN("Press Enter to Exit")
|
PrintN("Press Enter to Exit")
|
||||||
Input()
|
Input()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue