Configure CGI script » History » Version 4
Rob Tjalma, 08/29/2016 08:21 AM
1 | 1 | Rob Tjalma | h1. Configure CGI script |
---|---|---|---|
2 | 1 | Rob Tjalma | |
3 | 4 | Rob Tjalma | *BEFORE USE:* |
4 | 4 | Rob Tjalma | Create the database before using. See [[Database_structure]] |
5 | 4 | Rob Tjalma | |
6 | 1 | Rob Tjalma | Instructions about how to create a CGI script for connecting to the SQLite database. |
7 | 1 | Rob Tjalma | |
8 | 1 | Rob Tjalma | h3. Script example |
9 | 1 | Rob Tjalma | |
10 | 1 | Rob Tjalma | <pre> |
11 | 3 | Rob Tjalma | #!/bin/sh |
12 | 1 | Rob Tjalma | |
13 | 1 | Rob Tjalma | echo |
14 | 1 | Rob Tjalma | |
15 | 1 | Rob Tjalma | QUERY_STRING = "$QUERY_STRING" |
16 | 1 | Rob Tjalma | |
17 | 3 | Rob Tjalma | # The name of the database |
18 | 3 | Rob Tjalma | export DB_NAME="name.db" |
19 | 3 | Rob Tjalma | |
20 | 3 | Rob Tjalma | python path/to/file.py $QUERY_STRING $DB_NAME |
21 | 1 | Rob Tjalma | </pre> |
22 | 1 | Rob Tjalma | |
23 | 1 | Rob Tjalma | Very easy CGI script. |
24 | 1 | Rob Tjalma | The *QUERY_STRING* variable contains all the query parameters in the URL. |
25 | 1 | Rob Tjalma | |
26 | 1 | Rob Tjalma | _Example:_ |
27 | 2 | Rob Tjalma | <pre>http://example.example/webservice/test.cgi?q=value&callback=function</pre> |
28 | 1 | Rob Tjalma | |
29 | 1 | Rob Tjalma | *QUERY_STRING* will give you: |
30 | 1 | Rob Tjalma | <pre>q=value&callback=function</pre> |
31 | 3 | Rob Tjalma | |
32 | 3 | Rob Tjalma | Second argument is the name of the database. |
33 | 1 | Rob Tjalma | |
34 | 1 | Rob Tjalma | The python file in the repository takes one argument, the *QUERY_STRING* value. |