🎷 funky

simple call & response python to google cloud function


Table of Contents

  1. β›… Cloud Function
  2. πŸ”₯ try it out!
  3. πŸš™ usage
  4. πŸš‚ App Engine
  5. πŸ₯‘ setup
  6. 🎨 authors
  7. πŸ” license


β›… Cloud Function

πŸ”₯ try it out!


πŸš™ usage


πŸ€ Virtual Machine Instance

πŸ”₯ try it out!

test the live deployment of the gcloud socketio app πŸ–‡

βš’ setup

  1. create a new Google Cloud Platform VM instance under the (Compute Engine menu)[https://console.cloud.google.com/compute/] for your app in the Google Cloud Console
    Machine Type
    - 1 vCPU
    - 1 GB Memory
    - Ubuntu 18.04 LTS
    
  2. ssh into the VM instance by clicking the button under β€œremote access”, then perform the following commands:
    sudo apt update
    sudo apt install gunicorn python python-dev python3 python3-dev
    wget https://bootstrap.pypa.io/get-pip.py
    sudo python get-pip.py
    sudo pip install --upgrade virtualenv
    virtualenv --python python3 env
    sudo pip install eventlet flask python-socketio
    git clone https://github.com/insanj/funky && cd funky
    gunicorn -k eventlet -w 1 --bind 35.231.240.246:65080 wsgi
    

πŸš‚ App Engine

πŸ”₯ try it out!

test the live deployment of the gcloud flask app πŸ–‡

  1. run python funky.py <PARAM> to get a simple flask response via python

  2. go to https://funky.host/ to establish a socketio connection response via web browser

try connecting with more than one web browser to send messages to each other! try putting in a custom param to see a custom result based on the endpoint tree (such as πŸ—)!


πŸš™ usage

from flask import Flask
app = Flask(__name__)

@app.route('/<thing>')
def mirrorThing(thing):
	return thing
$ gcloud app deploy
Services to deploy:

descriptor:      [/funky/app.yaml]
source:          [/funky]
target project:  [funky-221323]
target service:  [default]
target version:  [20181102t210815]
target url:      [https://funky-221323.appspot.com]


Do you want to continue (Y/n)?  Y

Beginning deployment of service [default]...
╔════════════════════════════════════════════════════════════╗
╠═ Uploading 15 files to Google Cloud Storage               ═╣
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
File upload done.
Updating service [default]...done.
Setting traffic split for service [default]...done.
Deployed service [default] to [https://funky-221323.appspot.com]

You can stream logs from the command line by running:
  $ gcloud app logs tail -s default

To view your application in the web browser run:
  $ gcloud app browse

πŸ₯‘ setup


  1. (mostly optional) setup local Google Cloud Platform Python Development Environment
    • sudo apt install python python-dev python3 python3-dev
    • wget https://bootstrap.pypa.io/get-pip.py
    • sudo python get-pip.py
    • pip install --upgrade virtualenv
    • virtualenv --python python3 env
    • pip install google-cloud-storage
  2. create new app engine using a Python App Engine Standard Environment
    • new app engine
    • python standard environment
  3. download the Google Cloud SDK and setup the gcloud command
    • wget https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-223.0.0-linux-x86_64.tar.gz
    • tar zxvf google-cloud-sdk-223.0.0-linux-x86_64.tar.gz ~/google-cloud-sdk
    • cd ~ && ./google-cloud-sdk/install.sh
  4. initialize using gcloud init
    • requires logging into google account and setting up PATH
  5. deploy using gcloud app deploy

  6. enable websocket use by running the following command:

gcloud compute firewall-rules create default-allow-websockets --allow tcp:65080 --target-tags websocket --description "allow websocket traffic on port 65080"

using websockets requires a configured billing account linked to your app engine project. using the basic flask endpoints, however, does not.

add more dependancies by editing the requirements.txt file or following the custom library instructions

🎨 authors


julian weiss (insanj), (c) 2018. reach out on github!

πŸ” license


funky is licensed under gpl-3.0. see license file.