-
Notifications
You must be signed in to change notification settings - Fork 0
Web Server
The web servers for the bootcamp are deployed on Google Cloud Platform's Compute Engine.
The following describe how to set up a virtual machine on GCP. Step 2 describes the specific details used.
- Tutorial on how to setup a linux instance
- To match the bootcamp instance use:
- Machine Type: f1-micro (1vCPU, 614mb ram)
- Image: Ubuntu 16.04 LTS
- Firewall: Allow HTTP and HTTPS traffic
- Set up static IP address for web server (VPC Network > External IP addresses > type > static)
- Set up firewall rules (VPC Network > Firewall rules > Create firewall rule > name: flask > targets: All instances in network > source ip ranges: 0.0.0.0/0 > protocols and ports, tcp: 5000 > create)
- At GCP Compute Engine > Virtual Machines > click "SSH". A terminal will open.
Then, in the terminal, clone the git repo onto the web server
$ git clone https://github.com/runck014/gems_iot_bootcamp.git
- Run web_server_setup.sh script
$ bash gems_iot_bootcamp/web_server/web_server_setup.sh
Note: At this point, your web server should be up and running. You should see:
* Serving Flask app "XXXXXXXXX FLASK APP NAME"
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
- To access your web server from the internet, find the IP address at GCP > compute engine > vm instances > external IP > *copy and paste the IP address with the firewall port into a web browser, e.g. x.x.x.x:5000. You should see a "hello world" response if it worked correctly.
-
Change SSH configuration settings
-
Set user name and passwords
To start the web server, there are two steps.
- Kill the webserver
<ctrl> c
- Start the flask server
python NAME_OF_YOUR_APP.py
Often, you may want to edit files or navigate your file system while your flask app runs. TMUX is a tool that allows this. It provides tabs for a terminal environment. To start tmux:
- Start tmux
tmux attach
- Create new tab
<cmd> c
- See cheat sheet on tmux for more details
Insomnia and Postman are two common platforms to help interactively develop REST API's. They allow you to interact with a REST API via HTTP methods using a desktop application. Combined with print statements on a remote server, they are useful for learning and debugging.