Application » History » Version 2
Elmer de Looff, 2013-03-21 13:48
Use of uweb application explained and updated to current scripts
1 | 1 | Elmer de Looff | h1. Application |
---|---|---|---|
2 | 1 | Elmer de Looff | |
3 | 2 | Elmer de Looff | Provided with µWeb is a script named @uweb@ which when [[Installation|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. |
4 | 1 | Elmer de Looff | |
5 | 2 | Elmer de Looff | h2. Creating new µWeb projects |
6 | 1 | Elmer de Looff | |
7 | 2 | Elmer de Looff | 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: |
8 | 1 | Elmer de Looff | |
9 | 2 | Elmer de Looff | <pre><code class="bash"> |
10 | 2 | Elmer de Looff | uweb init boondoggle |
11 | 2 | Elmer de Looff | </code></pre> |
12 | 1 | Elmer de Looff | |
13 | 2 | Elmer de Looff | 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: |
14 | 1 | Elmer de Looff | |
15 | 1 | Elmer de Looff | <pre> |
16 | 2 | Elmer de Looff | +--------------------------------------------------------------+ |
17 | 2 | Elmer de Looff | | initializing new uWeb project 'boondoggle' | |
18 | 2 | Elmer de Looff | +--------------------------------------------------------------+ |
19 | 2 | Elmer de Looff | * copying uWeb base project directory |
20 | 2 | Elmer de Looff | * setting up router |
21 | 2 | Elmer de Looff | * setting up apache config |
22 | 2 | Elmer de Looff | +--------------------------------------------------------------+ |
23 | 2 | Elmer de Looff | | initialization complete - have fun with uWeb | |
24 | 2 | Elmer de Looff | +--------------------------------------------------------------+ |
25 | 1 | Elmer de Looff | </pre> |
26 | 1 | Elmer de Looff | |
27 | 2 | Elmer de Looff | h3. Error: Target already exists |
28 | 1 | Elmer de Looff | |
29 | 2 | Elmer de Looff | 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. |
30 | 1 | Elmer de Looff | |
31 | 2 | Elmer de Looff | *N.B.*: This will delete any and all existing data in the target directory. It will not _merge_ the µWeb project. |
32 | 1 | Elmer de Looff | |
33 | 2 | Elmer de Looff | h2. Controlling the local testing webserver |
34 | 1 | Elmer de Looff | |
35 | 2 | Elmer de Looff | LLAA tool used to control stuff |
36 | 1 | Elmer de Looff | |
37 | 2 | Elmer de Looff | h3. Listing µWeb projects |
38 | 1 | Elmer de Looff | |
39 | 2 | Elmer de Looff | µWeb comes preloaded with a set of two example projects, and now our project is listed as well: |
40 | 1 | Elmer de Looff | |
41 | 1 | Elmer de Looff | <pre> |
42 | 2 | Elmer de Looff | elmer@Penrose:~$ uweb list |
43 | 2 | Elmer de Looff | Overview of active sites: |
44 | 1 | Elmer de Looff | |
45 | 2 | Elmer de Looff | +------------+---------------------------------+-------------+ |
46 | 2 | Elmer de Looff | | Name | Router | Working dir | |
47 | 2 | Elmer de Looff | +------------+---------------------------------+-------------+ |
48 | 2 | Elmer de Looff | | boondoggle | boondoggle.router.boondoggle | /home/elmer | |
49 | 2 | Elmer de Looff | | logviewer | uweb.logviewer.router.logging | / | |
50 | 2 | Elmer de Looff | | uweb_info | uweb.uweb_info.router.uweb_info | / | |
51 | 2 | Elmer de Looff | +------------+---------------------------------+-------------+ |
52 | 1 | Elmer de Looff | </pre> |
53 | 1 | Elmer de Looff | |
54 | 2 | Elmer de Looff | We can see three projects here: |
55 | 2 | Elmer de Looff | * Our newly initialized @boondoggle@ project, aspiring to be the new social media synergy machine. |
56 | 2 | Elmer de Looff | * @logviewer@, which is a handy viewer for µWeb's SQLite logfiles |
57 | 2 | Elmer de Looff | * @uweb_info@, a demonstration project for various µWeb functionalities and abstractions. |
58 | 1 | Elmer de Looff | |
59 | 2 | Elmer de Looff | h3. Starting and stopping µWeb projects |
60 | 1 | Elmer de Looff | |
61 | 2 | Elmer de Looff | µ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: |
62 | 1 | Elmer de Looff | |
63 | 2 | Elmer de Looff | * The @logviewer@ runs on port 8001 |
64 | 2 | Elmer de Looff | * @uweb_info@ runs on port 8000 |
65 | 1 | Elmer de Looff | |
66 | 2 | Elmer de Looff | Starting a µWeb project using the @uweb@ application is simple enough: |
67 | 1 | Elmer de Looff | |
68 | 1 | Elmer de Looff | <pre> |
69 | 2 | Elmer de Looff | uweb start boondoggle |
70 | 1 | Elmer de Looff | </pre> |
71 | 1 | Elmer de Looff | |
72 | 2 | Elmer de Looff | 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. |
73 | 1 | Elmer de Looff | |
74 | 2 | Elmer de Looff | The development server can be stopped or restarted using the @stop@ and @restart@ commands: |
75 | 1 | Elmer de Looff | |
76 | 1 | Elmer de Looff | <pre> |
77 | 2 | Elmer de Looff | uweb stop boondoggle |
78 | 1 | Elmer de Looff | </pre> |
79 | 1 | Elmer de Looff | |
80 | 2 | Elmer de Looff | h3. Adding / removing and updating routers |
81 | 1 | Elmer de Looff | |
82 | 2 | Elmer de Looff | h3. Creating Apache configurations |