Travel Web Backend

    Manual

    We will use the Python version of the Travel Sample Web Backend which uses the Couchbase Python SDK to with with Couchbase Server Query Services.

    If you would prefer to use a docker container instead, please proceed to the docker section

    *Windows Users * The instructions in this section are for Windows users. Scroll to "Other Platforms" section for instructions for other platforms. - Install the Couchbase Python SDK Installer. This can be downloaded from Pypi website. Scroll to the section which lists the relevant installers and select the installer corresponding to appropriate version of Python that you have installed on your machine. win py installer - Clone the 5.0 branch of Travel Sample web app repo

    $ git clone -b 5.0 https://github.com/couchbaselabs/try-cb-python.git
    • Verify pip installation If you are developing on Windows, pip.exe will be found in "Scripts" sub directory under the Python installation directory. Add the path to the "Scripts" folder to the system’s PATH environment variable. You can follow instructions here to set your PATH variable. Verify that pip is recognized by typing the following in the cmd terminal. You should see the help menu

      pip
    • The application uses several Python libraries that need to be installed, this are listed in requirements.txt and can be automatically loaded using the pip command

      cd c:\path\to\try-cb-python
      pip install -r requirements.txt
    • Update the travel.py file to reflect the username and password that you have used during Couchbase Server install. This defaults to "Administrator" and "password"

      DEFAULT_USER = "Administrator"
      PASSWORD = 'password'
    • Now launch the Travel Web App

      $ python travel.py
      $ Running on http://localhost:8080/ (Press CTRL+C to quit)

      You may see an alert similar to one below requesting access to run the app. Make sure you select the "Allow access" option. python run 1

    Other Platforms * - *PREREQUISITE : First, install libcouchbase Core C SDK used by the Python SDK - Follow instructions here to install libcouchbase on your platform of choice

    • Clone the 5.0 branch of Travel Sample web app repo

      $ git clone -b 5.0 https://github.com/couchbaselabs/try-cb-python.git
    • We will run the Travel Web App in a Python virtual environment. First, check if virtualenv is installed on your system

      $ virtualenv --version
    • if virtualenv is not installed , you can use apt-get or pip to install it
      Run the following command
      $ sudo pip install virtualenv
    • Specify the folder to set up your virtual environment Run the following command

      $ virtualenv /path/to/try-cb-python/
    • Activate your environment by running "activate" Run the following command

      (try-cb-python) c:\Users\priya\try-cb-python\Scripts>

      You should see a prompt similar to one shown below

      $ (try-cb-python) Macintosh-2:try-cb-python mactester$
    • The application uses several Python libraries that need to be installed, this are listed in requirements.txt and can be automatically loaded using the pip command

      cd /path/to/try-cb-python
      pip install -r requirements.txt
    • Update the travel.py file to reflect the username and password that you have used during Couchbase Server install. This defaults to "Administrator" and "password"

      DEFAULT_USER = "Administrator"
      PASSWORD = 'password'
    • Now launch the Travel Web App

    python travel.py
    * Running on http://localhost:8080/ (Press CTRL+C to quit)

    Try it out

    • Open http://localhost:8080/ in your web browser

    • Verify that you see the login screen of the Travel Sample Web App as shown below try cb login =

    Docker (Local)

    NOTE : If you are running the Web App in a docker container, please make sure that you have the Couchbase Server and Sync Gateway running in containers as well. If not, please follow instructions here to install the server container and here to install sync gateway container.

    • Create a local docker network named "workshop" if one does not exist already. Open a terminal window and run the following command bash $ docker network ls $ docker network create -d bridge workshop

    • To run the application in a container, you will first get the docker image from Docker Cloud. Open a terminal window and run the following.

    bash $ docker pull connectsv/try-cb-python:6.0.1-server

    • Once the command has completed you can start the application with the following.

    bash $ docker run -it -p 8080:8080 --network workshop connectsv/try-cb-python:6.0.1-server

    You should then see the following in the console output.

    bash Running on http://0.0.0.0:8080/ (Press CTRL+C to quit) ## Try it out - Open http://localhost:8080/ in your web browser - Verify that you see the login screen of the Travel Sample Web App as shown below try cb login=