diff --git a/.gitignore b/.gitignore index 71e3b6e..569d333 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.idea/ .bash_history .env .gitconfig diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..7dea1d1 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +pyenv local 3.10.0 \ No newline at end of file diff --git a/Zoom-Discussion.md b/Zoom-Discussion.md new file mode 100644 index 0000000..9c65b74 --- /dev/null +++ b/Zoom-Discussion.md @@ -0,0 +1,8 @@ +In python project you don't commit dependencies to the project +so typically this would be required: pip install -r requirements.txt + +# TODOs +1. Why does installing packages fail???? +2. Do we need a .python-version file or a pyproject.yaml?? +3. Consistent build process +4. Readme for actions container or fwd? diff --git a/example.py b/example.py new file mode 100644 index 0000000..abfbd9c --- /dev/null +++ b/example.py @@ -0,0 +1,24 @@ +# Strongly vs Dynamic Languages +# Python is STRONGLY typed DYNAMIC language + +# https://www.bairesdev.com/blog/static-vs-dynamic-typing/ + +# STATIC vs DYNAMIC +# For STATIC languages your IDE/build it will complain at COMPILE time if you're doing some +# kind of operand on incompatible types +# for DYNAMIC languages type checking is done at RUNTIME + +# STRONG vs WEAKLY type +# A programing language that is strongly typed can either by dynamic or static +# Weakly-typed languages make conversions between unrelated types implicitly; +# whereas, strongly-typed languages don’t allow implicit conversions between unrelated types. + +# JAVASCRIPT it is weakly typed and dynamic this will run without a single fucking error +# value = 21; +# value = value + "dot"; +# console.log(value); +# 21dot + +myName = "Lou " + 3 # We get a squiggle because we don't allow implicit type conversion + +print(myName) diff --git a/img.png b/img.png new file mode 100644 index 0000000..9ca6103 Binary files /dev/null and b/img.png differ diff --git a/webapp.py b/webapp.py index 93eb135..fb1644d 100644 --- a/webapp.py +++ b/webapp.py @@ -63,13 +63,19 @@ def shorten_url(): response = prepare_response(short_url) return response -def save_url_to_database(short_url, long_url): + +# example of a default parameter, required arguments must go at the beginning of the argument list +def save_url_to_database(long_url, short_url="default"): conn = get_db_connection() conn.execute('INSERT INTO urls (short_url, long_url) VALUES (?, ?)', (short_url, long_url)) conn.commit() conn.close() + +# save_url_to_database(long_url="long_url") - example of using name parameters + + def prepare_response(short_url): return jsonify(short_url=os.getenv('REDIRECT_URL') + short_url)