Project

General

Profile

Application » History » Version 2

« Previous - Version 2/4 (diff) - Next » - Current version
Elmer de Looff, 2013-03-21 13:48
Use of uweb application explained and updated to current scripts


Application

Provided with µWeb is a script named uweb which when installed using pip will be located on your path, i.e. globally executable. With this application you can create and manage µWeb projects and webservers for testing purposes.

Creating new µWeb projects

New µWeb projects can be created (initialized) by running the uweb init command. With this, you have to specify the name of your project, as follows:

uweb init boondoggle

This creates a µWeb project named boondoggle in the current directory. All the necessary files are copied to this directory and a router configuration entry is made (more about that later). What's important now is picking the right name for your project (of course, you can change it, but a good name gets you going). The script will do its thing and tell you when it's done:

+--------------------------------------------------------------+
| initializing new uWeb project 'boondoggle'                   |
+--------------------------------------------------------------+
* copying uWeb base project directory
* setting up router
* setting up apache config
+--------------------------------------------------------------+
| initialization complete - have fun with uWeb                 |
+--------------------------------------------------------------+

Error: Target already exists

Sometimes you end up using the same really good name twice. µWeb will warn you that there's already a directory with the given name, it won't readily use this directory and destroy its contents. You can use the -f flag to force the initialization in that directory.

N.B.: This will delete any and all existing data in the target directory. It will not merge the µWeb project.

Controlling the local testing webserver

LLAA tool used to control stuff

Listing µWeb projects

µWeb comes preloaded with a set of two example projects, and now our project is listed as well:

elmer@Penrose:~$ uweb list
Overview of active sites:

 +------------+---------------------------------+-------------+
 | Name       | Router                          | Working dir |
 +------------+---------------------------------+-------------+
 | boondoggle | boondoggle.router.boondoggle    | /home/elmer |
 | logviewer  | uweb.logviewer.router.logging   | /           |
 | uweb_info  | uweb.uweb_info.router.uweb_info | /           |
 +------------+---------------------------------+-------------+
We can see three projects here:
  • Our newly initialized boondoggle project, aspiring to be the new social media synergy machine.
  • logviewer, which is a handy viewer for µWeb's SQLite logfiles
  • uweb_info, a demonstration project for various µWeb functionalities and abstractions.

Starting and stopping µWeb projects

µWeb projects by default run on port 8082 (and bind to all IP addresses on the machine, so they're also reachable by other people on the network). This can be configured by changing the configuration files for Standalone, and in fact the two projects that come with µWeb run on different ports:

  • The logviewer runs on port 8001
  • uweb_info runs on port 8000

Starting a µWeb project using the uweb application is simple enough:

uweb start boondoggle

You can then point your webbrowser to http://localhost:8082/ and you'll be greeted with a basic HTML page welcoming you to your new project.

The development server can be stopped or restarted using the stop and restart commands:

uweb stop boondoggle

Adding / removing and updating routers

Creating Apache configurations