This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, request, jsonify | |
from flask_sqlalchemy import SQLAlchemy | |
from flask_marshmallow import Marshmallow | |
from flask_restful import Resource, Api | |
app = Flask(__name__) | |
api = Api(app) | |
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///users.db' | |
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. Library imports | |
import uvicorn | |
from fastapi import FastAPI | |
# 2. Create the app object | |
app = FastAPI() | |
# 3. Index route, opens automatically on http://127.0.0.1:8000 | |
@app.get('/') | |
def index(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import uvicorn | |
from fastapi import FastAPI | |
app = FastAPI() | |
@app.get('/') | |
def index(): | |
''' | |
This is a first docstring. | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. Library imports | |
import pandas as pd | |
from sklearn.ensemble import RandomForestClassifier | |
from pydantic import BaseModel | |
import joblib | |
# 2. Class which describes a single flower measurements | |
class IrisSpecies(BaseModel): | |
sepal_length: float |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. Library imports | |
import uvicorn | |
from fastapi import FastAPI | |
from Model import IrisModel, IrisSpecies | |
# 2. Create app and model objects | |
app = FastAPI() | |
model = IrisModel() | |
# 3. Expose the prediction functionality, make a prediction from the passed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
new_measurement = { | |
'sepal_length': 5.7, | |
'sepal_width': 3.1, | |
'petal_length': 4.9, | |
'petal_width': 2.2 | |
} | |
response = requests.post('http://127.0.0.1:8000/predict', json=new_measurement) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(gapminder) | |
library(ggplot2) | |
library(dplyr) | |
library(shiny) | |
ui <- fluidPage( | |
titlePanel("Gapminder explorer", windowTitle = NULL), | |
plotOutput("line") | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(gapminder) | |
library(dplyr) | |
library(ggplot2) | |
ui <- fluidPage( | |
titlePanel("Gapminder explorer", windowTitle = NULL), | |
sidebarPanel( | |
width = 3, | |
tags$h4("Filter"), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import smtplib | |
from email.message import EmailMessage | |
EMAIL_ADDRESS = 'your_email_address' | |
EMAIL_PASSWORD = 'your_app_password' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
msg = EmailMessage() | |
msg['Subject'] = 'This is my first Python email' | |
msg['From'] = EMAIL_ADDRESS | |
msg['To'] = EMAIL_ADDRESS | |
msg.set_content('And it actually works') | |
with smtplib.SMTP_SSL('smtp.gmail.com', 465) as smtp: | |
smtp.login(EMAIL_ADDRESS, EMAIL_PASSWORD) | |
smtp.send_message(msg) |
OlderNewer