Application » History » Version 1
Elmer de Looff, 2012-11-08 14:42
1 | 1 | Elmer de Looff | h1. Application |
---|---|---|---|
2 | 1 | Elmer de Looff | |
3 | 1 | Elmer de Looff | h2. Initialize uweb project |
4 | 1 | Elmer de Looff | |
5 | 1 | Elmer de Looff | The easy way to initialize uweb is to type |
6 | 1 | Elmer de Looff | |
7 | 1 | Elmer de Looff | <pre> |
8 | 1 | Elmer de Looff | uweb init [your project name] |
9 | 1 | Elmer de Looff | </pre> |
10 | 1 | Elmer de Looff | |
11 | 1 | Elmer de Looff | This creates a folder in your current directory with the project name. |
12 | 1 | Elmer de Looff | When you don't pick a name uweb uses 'uweb_project' by default. |
13 | 1 | Elmer de Looff | You probably want pick a nice name because this is what makes your project unique like a little snow flake. |
14 | 1 | Elmer de Looff | |
15 | 1 | Elmer de Looff | <pre> |
16 | 1 | Elmer de Looff | uweb init snowflake |
17 | 1 | Elmer de Looff | </pre> |
18 | 1 | Elmer de Looff | |
19 | 1 | Elmer de Looff | <pre> |
20 | 1 | Elmer de Looff | -------------------------------------------- |
21 | 1 | Elmer de Looff | initializing uweb |
22 | 1 | Elmer de Looff | -------------------------------------------- |
23 | 1 | Elmer de Looff | cloning uweb source |
24 | 1 | Elmer de Looff | setting up router |
25 | 1 | Elmer de Looff | setting up apache config |
26 | 1 | Elmer de Looff | -------------------------------------------- |
27 | 1 | Elmer de Looff | initialization complete - have fun with uweb |
28 | 1 | Elmer de Looff | -------------------------------------------- |
29 | 1 | Elmer de Looff | </pre> |
30 | 1 | Elmer de Looff | |
31 | 1 | Elmer de Looff | This generates the snowflake uweb project and generates a folder named 'snowflake' in your current directory. The snowflake project contains multiple folders and files. |
32 | 1 | Elmer de Looff | In the next chapter we'll activate our project locally. |
33 | 1 | Elmer de Looff | |
34 | 1 | Elmer de Looff | If you already have a project with the same name, uweb gives you a warning and cancels initialization. |
35 | 1 | Elmer de Looff | |
36 | 1 | Elmer de Looff | <pre> |
37 | 1 | Elmer de Looff | Project already excist, use -f (force) to wipe project. |
38 | 1 | Elmer de Looff | </pre> |
39 | 1 | Elmer de Looff | |
40 | 1 | Elmer de Looff | If you somehow completely ruined your project and want a clean start add the 'f' (force) flag to remove your project and execute a clean initialization. |
41 | 1 | Elmer de Looff | |
42 | 1 | Elmer de Looff | <pre> |
43 | 1 | Elmer de Looff | uweb init snowflake -f |
44 | 1 | Elmer de Looff | </pre> |
45 | 1 | Elmer de Looff | |
46 | 1 | Elmer de Looff | The same effect can be recreated by deleting the project and initializing uweb as usual. |
47 | 1 | Elmer de Looff | |
48 | 1 | Elmer de Looff | h2. Start/stop local webserver |
49 | 1 | Elmer de Looff | |
50 | 1 | Elmer de Looff | 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'. |
51 | 1 | Elmer de Looff | |
52 | 1 | Elmer de Looff | <pre> |
53 | 1 | Elmer de Looff | python /home/user/snowflake/router/snowflake.py start |
54 | 1 | Elmer de Looff | </pre> |
55 | 1 | Elmer de Looff | |
56 | 1 | Elmer de Looff | Next you can open up your browser and navigate to: |
57 | 1 | Elmer de Looff | |
58 | 1 | Elmer de Looff | <pre> |
59 | 1 | Elmer de Looff | http://localhost:8082/ |
60 | 1 | Elmer de Looff | </pre> |
61 | 1 | Elmer de Looff | |
62 | 1 | Elmer de Looff | Uweb uses port 8082 locally by default. |
63 | 1 | Elmer de Looff | This brings you to the default uweb page which contains the text 'Hello µWeb'. |
64 | 1 | Elmer de Looff | This means you have successfully setup and started your own uweb project. |
65 | 1 | Elmer de Looff | |
66 | 1 | Elmer de Looff | To stop you local server, replace the 'start' command with 'stop' |
67 | 1 | Elmer de Looff | |
68 | 1 | Elmer de Looff | <pre> |
69 | 1 | Elmer de Looff | python /home/user/snowflake/router/snowflake.py stop |
70 | 1 | Elmer de Looff | </pre> |
71 | 1 | Elmer de Looff | |
72 | 1 | Elmer de Looff | When you make updates in your router, uweb usually don't update your changes manually. |
73 | 1 | Elmer de Looff | Type 'restart' to restart your local server with the new configurations. |
74 | 1 | Elmer de Looff | |
75 | 1 | Elmer de Looff | <pre> |
76 | 1 | Elmer de Looff | python /home/user/snowflake/router/snowflake.py restart |
77 | 1 | Elmer de Looff | </pre> |
78 | 1 | Elmer de Looff | |
79 | 1 | Elmer de Looff | h2. Setting up uWeb in Apache |
80 | 1 | Elmer de Looff | |
81 | 1 | Elmer de Looff | To setup uweb in apache, copy the apache.conf (in the root of your project) to your available apache sites. |
82 | 1 | Elmer de Looff | Uweb its default domain is your project name followed by local. |
83 | 1 | Elmer de Looff | |
84 | 1 | Elmer de Looff | <pre> |
85 | 1 | Elmer de Looff | ServerName [project_name].local |
86 | 1 | Elmer de Looff | </pre> |
87 | 1 | Elmer de Looff | |
88 | 1 | Elmer de Looff | change this to the desired domain name. |
89 | 1 | Elmer de Looff | |
90 | 1 | Elmer de Looff | <pre> |
91 | 1 | Elmer de Looff | ServerName snowflake.com |
92 | 1 | Elmer de Looff | </pre> |
93 | 1 | Elmer de Looff | |
94 | 1 | Elmer de Looff | Next add this domain to your hosts and reload apache. |
95 | 1 | Elmer de Looff | Now your uweb project should work in Apache. |
96 | 1 | Elmer de Looff | |
97 | 1 | Elmer de Looff | *Warning* |
98 | 1 | Elmer de Looff | Renaming/moving your project will result in a broken apache config file. |
99 | 1 | Elmer de Looff | When you rename your project, remember to adjust the apache.conf file to the new name / location |
100 | 1 | Elmer de Looff | |
101 | 1 | Elmer de Looff | h2. Quick router controls |
102 | 1 | Elmer de Looff | |
103 | 1 | Elmer de Looff | To easily control uweb routers, there are a number of actions on the uWeb application, listed below: |
104 | 1 | Elmer de Looff | |
105 | 1 | Elmer de Looff | <pre> |
106 | 1 | Elmer de Looff | uweb [list|start|stop|restart|add|remove] -n [project name] |
107 | 1 | Elmer de Looff | </pre> |
108 | 1 | Elmer de Looff | |
109 | 1 | Elmer de Looff | Each project you create is added to je uweb router location file. |
110 | 1 | Elmer de Looff | This file contains the router locations of all your uweb project. |
111 | 1 | Elmer de Looff | Calling the sites argument will display all projects and there route locations |
112 | 1 | Elmer de Looff | |
113 | 1 | Elmer de Looff | <pre> |
114 | 1 | Elmer de Looff | $ uweb sites |
115 | 1 | Elmer de Looff | snowflake: /home/codehunger/snowflake/router/snowflake.py |
116 | 1 | Elmer de Looff | </pre> |
117 | 1 | Elmer de Looff | |
118 | 1 | Elmer de Looff | In this example you see only one uweb project. |
119 | 1 | Elmer de Looff | This project is called 'snowflake' and the router location is '/home/codehunger/snowflake/router/snowflake.py' |
120 | 1 | Elmer de Looff | |
121 | 1 | Elmer de Looff | To start the 'snowflake' router you can simpely call uweb to start the snowflake router. |
122 | 1 | Elmer de Looff | |
123 | 1 | Elmer de Looff | <pre> |
124 | 1 | Elmer de Looff | $ uweb start -n snowflake |
125 | 1 | Elmer de Looff | Starting ... |
126 | 1 | Elmer de Looff | </pre> |
127 | 1 | Elmer de Looff | |
128 | 1 | Elmer de Looff | The n option should contain the name of your project. |
129 | 1 | Elmer de Looff | This could also be used to |
130 | 1 | Elmer de Looff | |
131 | 1 | Elmer de Looff | restart the router: |
132 | 1 | Elmer de Looff | <pre> |
133 | 1 | Elmer de Looff | $ uweb restart -n snowflake |
134 | 1 | Elmer de Looff | Stopping ... |
135 | 1 | Elmer de Looff | Starting ... |
136 | 1 | Elmer de Looff | </pre> |
137 | 1 | Elmer de Looff | |
138 | 1 | Elmer de Looff | stop the router: |
139 | 1 | Elmer de Looff | <pre> |
140 | 1 | Elmer de Looff | $ uweb stop -n snowflake |
141 | 1 | Elmer de Looff | Stopping ... |
142 | 1 | Elmer de Looff | </pre> |
143 | 1 | Elmer de Looff | |
144 | 1 | Elmer de Looff | When you add a uweb website (from a repository for example), uweb need to be updated. |
145 | 1 | Elmer de Looff | To add a path to the uwebsites use the 'add' argument. |
146 | 1 | Elmer de Looff | |
147 | 1 | Elmer de Looff | <pre> |
148 | 1 | Elmer de Looff | $ uweb sites |
149 | 1 | Elmer de Looff | snowflake: /home/codehunger/snowflake/router/snowflake.py |
150 | 1 | Elmer de Looff | $ uweb add -n foreign_snowflake -r /home/codehunger/foreign_snowflake/router/snowflake.py |
151 | 1 | Elmer de Looff | $ uweb sites |
152 | 1 | Elmer de Looff | foreign_snowflake: /home/codehunger/foreign_snowflake/router/snowflake.py |
153 | 1 | Elmer de Looff | snowflake: /home/codehunger/snowflake/router/snowflake.py |
154 | 1 | Elmer de Looff | </pre> |
155 | 1 | Elmer de Looff | |
156 | 1 | Elmer de Looff | The -n option contains the project name. |
157 | 1 | Elmer de Looff | The -r is the router location. |
158 | 1 | Elmer de Looff | |
159 | 1 | Elmer de Looff | In this example a project is added to the uweb sites. |
160 | 1 | Elmer de Looff | As you can see 'uweb sites' first printed 1 record and after adding a new site it printed 2 records. |
161 | 1 | Elmer de Looff | |
162 | 1 | Elmer de Looff | When you move your project the router links are not directing to your router anymore. |
163 | 1 | Elmer de Looff | You can update your router location with the -f (force) flag. |
164 | 1 | Elmer de Looff | |
165 | 1 | Elmer de Looff | <pre> |
166 | 1 | Elmer de Looff | $ uweb add -f -n foreign_snowflake -r /home/bob/snowflake/router/snowflake.py |
167 | 1 | Elmer de Looff | </pre> |
168 | 1 | Elmer de Looff | |
169 | 1 | Elmer de Looff | This updates the 'foreign_snowflake' record with a new router location. |
170 | 1 | Elmer de Looff | The previous router location is overwritten by the new location. |