Re: Euphoria MVC updates
- Posted by jmduro Nov 06, 2021
- 3266 views
I found one of my errors: I was missing the templates folder. euphoria-mvc does not warn about missing files.
I added the templates folder with files layout.html, index.html and user.html and somme logging.
├───conf ├───logs ├───templates ├───tmp └───www
I still get the same "500 - Internal Server Error" with following code (modified example3.ex):
-- -- This is just a basic example of the path routing engine. -- include std/map.e include std/filesys.e include std/search.e include std/io.e include std/pretty.e include mvc/app.e include mvc/template.e include mvc/logger.e if search:ends( "examples", current_dir() ) then -- make sure we can find our templates -- if we're in the 'examples' directory set_template_path( "../templates" ) end if function user_id( object request ) log_info( "user_id: request: %s", {pretty_sprint(request, {2})} ) integer id = map:get( request, "id", -1 ) map response = map:new() map:put( response, "title", "User" ) map:put( response, "id", id ) return render_template( "user.html", response ) end function app:route( "/user/<id:integer>", "user_id" ) function user_name( object request ) log_info( "user_name: request: %s", {pretty_sprint(request, {2})} ) sequence name = map:get( request, "name", "undefined" ) map response = map:new() map:put( response, "title", "User" ) map:put( response, "name", name ) return render_template( "user.html", response ) end function app:route( "/user/<name:string>", "user_name" ) function index( object request ) log_info( "index: request: %s", {pretty_sprint(request, {2})} ) map response = map:new() map:put( response, "title", "Index" ) return render_template( "index.html", response ) end function app:route( "/index", "index" ) app:route( "/", "index" ) set_log_output("!debug.log") -- overwrite debug.log each time set_log_level( LOG_DEBUG ) app:run()
The debug log doesn't show much information:
2021/11/06 10:16:41 INFO set_log_output@logger.e:212 Logging to "debug.log" 2021/11/06 10:16:41 DEBUG add_function@template.e:133 registered function "url_for" with params {{"name"},{"response",0}} at routine id 37 2021/11/06 10:16:41 DEBUG add_function@template.e:133 registered function "get_current_route" with params "" at routine id 38 2021/11/06 10:16:41 DEBUG add_function@template.e:133 registered function "get_current_path" with params "" at routine id 39
Jean-Marc