Project

General

Profile

Configure CGI script » History » Version 3

Rob Tjalma, 08/26/2016 01:27 PM

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