Location for XML configuration file in Wt distribution - and other help needed

Added by Osman Zakir 2 months ago

I want to use Wt for a C++ web app that I plan to create for a CS final project. I need to find the XML configuration that contains the line that I need to add my API key to in order to make use of the Google Maps API. I was told that I can find it in "/etc/wt/wt_config.xml", but I looked in the files I have and I can't find the etc/ folder anywhere. Could someone please help me out with this?

Also, it'd be much appreciated I could get a list of what Wt libraries depend on what Boost libraries, if any, so that I can link them all correctly to my project. And if someone would be kind as to point me to a good set of tutorials for Wt that can help me out when reading the ones on the Wt official site, that would also be a great help. Thanks.


Replies (12)

RE: Location for XML configuration file in Wt distribution - and other help needed - Added by Osman Zakir 2 months ago

Sorry for the double post.

Update: I found the wt_config.xml file on GitHub. I just need to know where to add my API key on it and also what the shortcut way is for specifying the Wt root, so that I can specify the location of the file itself so that the rest of Wt would know where this file is; it's the "application settings" tag with the "location" attribute being where the path to the file is specified, right? Or am I misunderstanding?

RE: Location for XML configuration file in Wt distribution - and other help needed - Added by Wim Dumon 2 months ago

This is an example wt_config.xml that adds a number of properties:
https://github.com/emweb/wt/blob/master/examples/widgetgallery/approot/wt_config.xml
Your google maps API key can likewise be configured as a property.

With respect to the location attribute: an asterisk means 'apply to all applications' and is what I usually use as I don't often share config files for multiple applications.

You can also specify something to apply the configuration for one specific application only, as explained in wt_config.xml:

    <!-- Override settings for specific applications.

       Location refers to physical filesystem location of the
       application. The application prints this location (which
       corresponds to argv[0]) to the log file on startup, and this
       should match exactly.
      -->
    <!--
    <application-settings
       location="/var/www/localhost/wt-examples/hello.wt">
    </application-settings>
    -->

Note that argv0 is not necessarily the full path, it can depend on how the program was exactly started. Look at the first output in the wt log to know the location of your binary.

Then write wt_config.xml to some location. Start up wt with the -c parameter to indicate where your config file is located.
For example:

hello.wt -c c:/abc/wt_config.xml --docroot c:/mydocroot --http-address 0.0.0.0 --http-port 8080

Wim.

RE: Location for XML configuration file in Wt distribution - and other help needed - Added by Osman Zakir 2 months ago

So I create a tag "API-Key" and put the key there? And if so, I think it should go somewhere below "user-agents", but would that be a good idea?

RE: Location for XML configuration file in Wt distribution - and other help needed - Added by Wim Dumon about 1 month ago

Oops seems I linked a bad example of a wt_config.xml for demonstration of properties. This is better:
https://github.com/emweb/wt/blob/master/examples/hangman/wt_config.xml

<server>
  <application-settings location="*">
    <properties>
       <property name="google_api_key">XXX1234XXX</property>
    </properties>
  </application-settings>
</server>

RE: Location for XML configuration file in Wt distribution - and other help needed - Added by Osman Zakir about 1 month ago

Thanks. Fixed on my end.

My binary build of Wt didn't come with an "etc" folder, so I made it manually. I don't know what else to put in there. The "application-settings" tag needs to specify the location of the wt_config.xml file, right? If so, do I have to put "docroot/etc/wt/wt_config.xml" as the location (how do I specify the root, though? I just say "docroot", or do I have to type out the path to the root?)?

I found the Wt class for Google Maps just a bit ago. Now I just want to know how to add geolocation functionality and create a custom widget for currency conversions that would take information on conversion factors from the web in real time somehow, maybe by delegating the actual task for getting the information to other widgets and then updating the information in the application. I'd also like to add a database backend so that the application can send the country part of the user's location to the server, getting the server to query the database for updated currency and other regional information. I need to find a way to get the updated info to the database first, of course.

I also want to let the user see the same information for any other place in the world, by typing the name of that location in a search bar. In addition, the application should also access to Google News for a given location if the user wants to see that.

If someone can help me out with finding out how to do all of this, it'd be appreciated. I'll also keep reading tutorials and documentation on the Wt website as well, but I'd also like some additional information and help to go with it. Especially for custom widgets I'll need to make and what widgets I already have available from the library to use.

Speaking of the library, there's something else I'm worried about as well: how do I know what Boost libraries to link with a given application? And it seems like I always need to find and copy-paste a whole bunch of DLLs to be able to run a given application; isn't there a way to have those DLLs get generated in the directory that the .exe file is in whenever I compile the application so that I don't have to get them from the Wt distribution every time? Also, what happens when a user that doesn't have those DLLs navigates to the application from the browser? Will it be enough if only I have those DLLs?

RE: Location for XML configuration file in Wt distribution - and other help needed - Added by Osman Zakir about 1 month ago

I also still have trouble being able to tell what Wt headers to #include. Right now I'm trying to create that Hangman app. I'm including the same headers as in the Hello one, but I'm not sure if it'll be enough or if I'll need more.

RE: Location for XML configuration file in Wt distribution - and other help needed - Added by Wim Dumon about 1 month ago

No, location is the executable name, not the location of wt_config.xml. To know what to put there, look at the first output in the wt log when you start your binary, or simply put '*' (matches for all).

No, wt_config.xml does not belong in docroot. All files in docroot can be accessed throught HTTP, which is not the intention for wt_config.xml. The docroot is a mandatory command line option. To specify where your wt_config.xml is, use the -c startup option: -c c:/here/is/my/wt_config.xml.

What binary build of Wt are you using? /etc/wt is typical for unix environments.

Wt currently does not contain support for the location API. I think it's a valuable addition, please submit a feature request (under 'New Issues' here in redmine).

Microsoft has a tool, called depends.exe, which tells you exactly what DLLs an application uses. Wt is not different from any other Windows application in this respect.

For header files: in the reference documentation, near the top of the file, the required include statement is shown to use the class you're looking at.

Best regards,
Wim.

RE: Location for XML configuration file in Wt distribution - and other help needed - Added by Osman Zakir about 1 month ago

I'm using the Windows one.

By "root" I meant the Wt root (not my own app's root).

I'll submit that feature request. Thanks for the tip.

RE: Location for XML configuration file in Wt distribution - and other help needed - Added by Osman Zakir about 1 month ago

I'll ask this here, too: I could still write my own code for getting the user's geolocation, right? If so, how?

RE: Location for XML configuration file in Wt distribution - and other help needed - Added by Wim Dumon about 1 month ago

Create a JSignal to which you attach a handler in C++. Then call WWidget::doJavascript() to start the geolocation query. In the result callback, trigger the JSignal from JavaScript.

wim.

RE: Location for XML configuration file in Wt distribution - and other help needed - Added by Osman Zakir about 1 month ago

Thanks. So I have to pass arguments to WWidget::doJavaScript() for the geolocation query? Or is that the callback you're talking about which is the argument to that function?

RE: Location for XML configuration file in Wt distribution - and other help needed - Added by Osman Zakir about 1 month ago

I've recently completed Harvardx's CS course, Introduction to Computer Science (CS50) and I have to create my own piece of software for its final project. I thought to try to create a web app in C++ for that. For reference here's the specification for the final project:

[This is the first paragraph in "Overview"]:

The climax of this course is its final project. The final project is your opportunity to take your newfound savvy with programming out for a spin and develop your very own piece of software. So long as your project draws upon this course’s lessons, the nature of your project is entirely up to you. You may implement your project in any language(s). You are welcome to utilize infrastructure other than the CS50 Appliance. All that we ask is that you build something of interest to you, that you solve an actual problem, that you impact your community, or that you change the world. Strive to create something that outlives this course.

The way I thought to try to "change the world" was to show that C++ isn't as hard to use as people think. I wanted to create a web application and make its public, especially if said code turns out to be simple enough, to illustrate that. But I also want an app that would be good as a final project and I'm not sure even now if my current idea (Google Maps API plus currency converter) is good enough. So some advice would be appreciated.

I've learned HTML, CSS and JavaScript, as well as C and Python, in CS50 and some other online tutorials. I'm also reading an intro book written by Dr. Stroustrup on C++ (Programming: Principles and Practice Using C++ 2nd Edition), plus I've also read other tutorials on C++ as well. But yes, I'm still learning and this app is for a final project as well.

In Dr. Stroustrup's book, he's having readers use GUI interface library he wrote that uses FLTK. We're using FLTK indirectly though that interface library, though some exercises in the book also have us define our own classes (and we of course have to use some FLTK functions directly for that). But I'm still new to GUI and I haven't learned enough about FLTK yet to be able to use it myself directly. And I have even touched Qt yet. So I was wondering if I should first learn those before getting to back to Wt, since it's based on Qt (and FLTK also seems to use widgets)?

And then I'd like a good hands-on tutorial or something that I can use to learn how to use all of the widgets in Wt. Not just through the examples but also actual tutorials based on them. Advanced tutorials for the more complex widgets. I'm reading up the reference manuals and stuff on the site, but I also want to be able to try it all out by writing code so I can understand by seeing it in action myself by using it all firsthand.

The reason I thought about making a currency converter app is related to one of the exercises I had to do in PPP2. A currency converter. The thing with that one is that it's static; I have to manually look up currency conversion rates on the web for it to work and those rates keep changing on a daily basis or so. So I thought I'd try to automate it by creating a web application, but the problem is that that's not really something new that hasn't been done yet. There are tons of good online currency converters out there already, so another one being added to the bunch wouldn't do much good for the world. That's why I'd also like some other ideas for a good C++ web app I could write that could show that C++ isn't hard as people think (and one that preferably also shows off C++'s power, though I guess I don't especially need to show that off like the lack of difficulty in using the language since most, if not all, of the programmers out there don't necessarily doubt the power of C++).

If you want to know what CS50 is, please try looking it up on edx.org (that's where I'm taking it).

(1-12/12)