Project

General

Profile

Application » History » Version 2

Version 1 (Elmer de Looff, 2012-11-08 14:42) → Version 2/4 (Elmer de Looff, 2013-03-21 13:48)

h1. Application

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.

h2. Creating new µWeb projects Initialize uweb project

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

<pre><code class="bash"> <pre>
uweb init boondoggle [your project name]
</code></pre> </pre>

This creates a µWeb project named @boondoggle@ folder in the your current directory. All directory with the necessary files are copied to project name.
When you don't pick a name uweb uses 'uweb_project' by default.
You probably want pick a nice name because
this directory and a router configuration entry is made (more about that later). What's important now is picking the right name for what makes your project (of course, you can change it, but unique like a good name gets you going). The script will do its thing and tell you when it's done: little snow flake.

<pre>
+--------------------------------------------------------------+ uweb init snowflake
| </pre>

<pre>
--------------------------------------------
initializing new uWeb project 'boondoggle' | uweb
+--------------------------------------------------------------+ --------------------------------------------
* copying uWeb base project directory cloning uweb source
* setting up router
* setting up apache config
+--------------------------------------------------------------+ --------------------------------------------
| initialization complete - have fun with uWeb | uweb
+--------------------------------------------------------------+ --------------------------------------------
</pre>

h3. Error: Target already exists This generates the snowflake uweb project and generates a folder named 'snowflake' in your current directory. The snowflake project contains multiple folders and files.
In the next chapter we'll activate our project locally.


Sometimes If you end up using the same really good name twice. µWeb will warn you that there's already have a directory project with the given same name, it won't readily uweb gives you a warning and cancels initialization.

<pre>
Project already excist,
use this directory -f (force) to wipe project.
</pre>

If you somehow completely ruined your project
and destroy its contents. You can use want a clean start add the @-f@ 'f' (force) flag to force remove your project and execute a clean initialization.

<pre>
uweb init snowflake -f
</pre>

The same effect can be recreated by deleting
the initialization in that directory. project and initializing uweb as usual.

*N.B.*: h2. Start/stop local webserver

uweb works with router files. A router usually represents a domain. To start a webserver navigate to your router (in the project's router folder) and type 'start'.

<pre>
python /home/user/snowflake/router/snowflake.py start
</pre>

Next you can open up your browser and navigate to:

<pre>
http://localhost:8082/
</pre>

Uweb uses port 8082 locally by default.
This will delete any and all existing data in brings you to the target directory. It will not _merge_ default uweb page which contains the µWeb text 'Hello µWeb'.
This means you have successfully setup and started your own uweb
project.

h2. Controlling To stop you local server, replace the local testing webserver 'start' command with 'stop'

LLAA tool used <pre>
python /home/user/snowflake/router/snowflake.py stop
</pre>

When you make updates in your router, uweb usually don't update your changes manually.
Type 'restart'
to control stuff restart your local server with the new configurations.

h3. Listing µWeb projects <pre>
python /home/user/snowflake/router/snowflake.py restart
</pre>


µWeb comes preloaded with a set h2. Setting up uWeb in Apache

To setup uweb in apache, copy the apache.conf (in the root
of two example projects, and now our your project) to your available apache sites.
Uweb its default domain is your
project is listed as well: name followed by local.

<pre>
elmer@Penrose:~$ uweb list ServerName [project_name].local
Overview of active sites:

+------------+---------------------------------+-------------+
| Name | Router | Working dir |
+------------+---------------------------------+-------------+
| boondoggle | boondoggle.router.boondoggle | /home/elmer |
| logviewer
</pre>

change this to the desired domain name.

<pre>
ServerName
| uweb.logviewer.router.logging | / |
| uweb_info | uweb.uweb_info.router.uweb_info | / |
+------------+---------------------------------+-------------+
snowflake.com
</pre>

We can see three projects here: Next add this domain to your hosts and reload apache.
* Our newly initialized @boondoggle@ Now your uweb project should work in Apache.

*Warning*
Renaming/moving your project will result in a broken apache config file.
When you rename your
project, aspiring remember to be adjust the apache.conf file to the new social media synergy machine. name / location

h2. Quick router controls

To easily control uweb routers, there are a number of actions on the uWeb application, listed below:

<pre>

* @logviewer@, which uweb [list|start|stop|restart|add|remove] -n [project name]
</pre>

Each project you create
is a handy viewer for µWeb's SQLite logfiles added to je uweb router location file.
* @uweb_info@, a demonstration project for various µWeb functionalities This file contains the router locations of all your uweb project.
Calling the sites argument will display all projects
and abstractions. there route locations

h3. Starting <pre>
$ uweb sites
snowflake: /home/codehunger/snowflake/router/snowflake.py
</pre>

In this example you see only one uweb project.
This project is called 'snowflake'
and stopping µWeb projects the router location is '/home/codehunger/snowflake/router/snowflake.py'

µWeb projects by default run on port 8082 (and bind To start the 'snowflake' router you can simpely call uweb to all IP addresses on start the machine, so they're also reachable by other people on snowflake router.

<pre>
$ uweb start -n snowflake
Starting ...
</pre>

The n option should contain
the network). name of your project.
This can could also be configured by changing used to

restart
the configuration files for [[Standalone]], and in fact router:
<pre>
$ uweb restart -n snowflake
Stopping ...
Starting ...
</pre>

stop
the two projects that come with µWeb run on different ports:

* The @logviewer@ runs on port 8001
router:
* @uweb_info@ runs on port 8000 <pre>
$ uweb stop -n snowflake
Stopping ...
</pre>


Starting When you add a µWeb project using uweb website (from a repository for example), uweb need to be updated.
To add a path to
the @uweb@ application is simple enough: uwebsites use the 'add' argument.

<pre>
$ uweb start boondoggle sites
snowflake: /home/codehunger/snowflake/router/snowflake.py
$ uweb add -n foreign_snowflake -r /home/codehunger/foreign_snowflake/router/snowflake.py
$ uweb sites
foreign_snowflake: /home/codehunger/foreign_snowflake/router/snowflake.py
snowflake: /home/codehunger/snowflake/router/snowflake.py
</pre>

You The -n option contains the project name.
The -r is the router location.

In this example a project is added to the uweb sites.
As you
can then point your webbrowser to http://localhost:8082/ see 'uweb sites' first printed 1 record and you'll be greeted with after adding a basic HTML page welcoming new site it printed 2 records.

When
you move your project the router links are not directing to your new project.

The development server
router anymore.
You
can be stopped or restarted using update your router location with the @stop@ and @restart@ commands: -f (force) flag.

<pre>
$ uweb stop boondoggle add -f -n foreign_snowflake -r /home/bob/snowflake/router/snowflake.py
</pre>

h3. Adding / removing and updating routers

h3. Creating Apache configurations
This updates the 'foreign_snowflake' record with a new router location.
The previous router location is overwritten by the new location.