Skip to content

Instantly share code, notes, and snippets.

View jslvtr's full-sized avatar

Jose Salvatierra jslvtr

View GitHub Profile
@jslvtr
jslvtr / reply.py
Created April 3, 2023 14:02
Introduction to pytest: A Beginner's Guide (https://youtu.be/Kt6QqGoAlvI)
import datetime
class Reply:
def __init__(self, body: str, user: str, created: datetime.datetime) -> None:
self.body = body
self.user = user
self.created = created
def __repr__(self) -> str:
@jslvtr
jslvtr / .python-version
Created January 18, 2023 18:26
Barebones Flask-Smorest API showing filtering with query string arguments
3.11
@jslvtr
jslvtr / index.html
Created September 12, 2020 12:40
Web Developer Bootcamp with Flask and Python - Learning HTML Project [Step 1]
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1>I'm learning HTML and CSS!</h1>
<p>Hello, my name is Rolf Smith. I'm learning about web development, and I'm starting with HTML and CSS.</p>
<p>With HTML and CSS, I can make all sorts of websites. HTML and CSS are the most important languages to learn!</p>
</body>
</html>
@jslvtr
jslvtr / index.html
Created September 12, 2020 12:40
Web Developer Bootcamp with Flask and Python - Learning HTML Project [Step 2]
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<img class="profile" src="profile.png" alt="Rolf's profile picture." />
<h1>I'm learning HTML and CSS!</h1>
<p>Hello, my name is Rolf Smith. I'm learning about web development, and I'm starting with HTML and CSS.</p>
<p>With HTML and CSS, I can make all sorts of websites. HTML and CSS are the most important languages to learn!</p>
<p>This website's code looks like this:</p>
@jslvtr
jslvtr / index.html
Created September 12, 2020 12:39
Web Developer Bootcamp with Flask and Python - Learning HTML Project [Step 3]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
/>
<title>Rolf Smith - Learning HTML</title>
<link rel="stylesheet" href="style.css" />
@jslvtr
jslvtr / app.py
Created September 4, 2020 14:48
Complete code for our "Dynamic Web Pages" YouTube video under our Flask Tutorial for Beginners series: https://youtu.be/CHRikEvvcUc
from flask import Flask, render_template, request
app = Flask(__name__)
transactions = []
@app.route("/", methods=["GET", "POST"])
def home():
print(request.form)
return render_template("form.html")
@jslvtr
jslvtr / app.py
Created August 29, 2020 19:08
How to receive form data with Flask
from flask import Flask, render_template, request
app = Flask(__name__)
@app.route("/", methods=["GET", "POST"])
def home():
print(request.form)
print(request.form.get("account"))
return render_template("form.html")
@jslvtr
jslvtr / form.html
Created August 21, 2020 15:59
The HTML and CSS Code for our Flask Tutorial for Beginners video (https://youtu.be/lIGKKnfLobA)
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Personal finance</title>
<link rel="stylesheet" href="./style.css" />
</head>
<body>
<h1>Add transaction</h1>
<form>
@jslvtr
jslvtr / test_list_reversal.py
Last active May 30, 2019 07:58
Introduction to unit testing with Python (https://blog.tecladocode.com/introduction-to-unit-testing-with-python/) — final complete code
from unittest import TestCase
from typing import List
def has_mixed_types(list_: List):
first = type(list_[0])
return any(not isinstance(t, first) for t in list_)
def reverse_list(original: List) -> List:
if has_mixed_types(original):
raise ValueError("The list to be reversed should have homogeneous types.")
@jslvtr
jslvtr / send_email.py
Created April 7, 2018 14:27
Sending e-mails with Python
import smtplib
from email.message import EmailMessage
email = EmailMessage()
email['Subject'] = 'Test email'
email['From'] = '[email protected]'
email['To'] = '[email protected]'