Re: Euphoria MVC updates

new topic     » goto parent     » topic index » view thread      » older message » newer message
jmduro said...

local_path is not defined.

Yes, a typo on my part, sorry about that.

jmduro said...

I thought it could be local_file instead but that's wrong:

2020/11/26 11:41:13  INFO static@mysql_users.ex:22 path_info = "\"/static/css/w3.css\"" 
2020/11/26 11:41:13  INFO static@mysql_users.ex:31 local_file = "\"C:\\\\Users\\\\duro\\\\Documents\\\\mysql_users\\\\examples\\\\static\\\\css\\\\w3.css\"" 
2020/11/26 11:41:13  INFO client_handler@server.e:140 "127.0.0.1" "GET" "/static/css/w3.css" "404 Not Found" 

No, that's right. The problem in the example you provided is that "static" is not in the "examples" directory, so the file indeed does not exist.

This is the layout of the zip file you posted:

mysql_users\ 
  examples\ 
    mysql.e 
    mysql_users.ex 
  static\ 
    css\ 
      w3.css 
  templates\ 
    insert.html 
    login.html 
    main.html 
    users.html 
  libmariadb.dll 
  users.sql 

I recommend putting the main app file in the root directory for your project, and then other directories like "static" and "templates" can be easily referenced from there.

So your project should look more like this:

mysql_users\ 
  static\ 
    css\ 
      w3.css 
  templates\ 
    insert.html 
    login.html 
    main.html 
    users.html 
  libmariadb.dll 
  mysql.e 
  mysql_users.ex 
  users.sql 

And then run:

eui mysql_users.ex 

And your static route will find the correct path to "w3.css"

Logging Targets

The logger outputs to STDERR by default. You're changing this to "debug.log" which is helpful, but you can also target multiple outputs, like this:

set_log_output({ STDOUT, "debug.log" }) 

When writing to files, the logger defaults to append mode. If you want to overwrite the file each time, prepend the filename with an exclamation mark:

set_log_output({ STDOUT, "!debug.log" }) -- overwrite debug.log each time 

Part of the idea of the logger is to have it color-code its output to the console to make it easier to read in real-time while the application is running.

Logging Formats

You don't need to pretty-print data you send to the logger routines. They're already built to pretty-print anything that isn't already a string. So you're just needlessly double-escaping things like quotes and backslashes,

So you can change this:

sequence path_info = map:get( request, "PATH_INFO" ) 
log_info( "path_info = %s", {pretty_sprint(path_info, {2})} ) 

2020/11/26 11:41:13  INFO static@mysql_users.ex:22 path_info = "\"/static/css/w3.css\"" 
2020/11/26 11:41:13  INFO static@mysql_users.ex:31 local_file = "\"C:\\\\Users\\\\duro\\\\Documents\\\\mysql_users\\\\examples\\\\static\\\\css\\\\w3.css\"" 

To just this:

sequence path_info = map:get( request, "PATH_INFO" ) 
log_info( "path_info = %s", {path_info} ) 

2020/11/26 11:41:13  INFO static@mysql_users.ex:22 path_info = "/static/css/w3.css" 
2020/11/26 11:41:13  INFO static@mysql_users.ex:31 local_file = "C:\\Users\\duro\\Documents\\mysql_users\\examples\\static\\css\\w3.css" 

Part of the idea of Euphoria MVC is to reduce the friction on these kinds of things and help you write cleaner, simpler code.

-Greg

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu