Beispiel #1
0
#################################################
# Database Setup
#################################################

from flask_sqlalchemy import SQLAlchemy

app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get(
    'DATABASE_URL', '') or "sqlite:///db.sqlite"

# Remove tracking modifications
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

db = SQLAlchemy(app)

Pet = create_classes(db)


# create route that renders index.html template
@app.route("/")
def home():
    return render_template("index.html")


# Query the database and send the jsonified results
@app.route("/send", methods=["GET", "POST"])
def send():
    if request.method == "POST":
        name = request.form["petName"]
        lat = request.form["petLat"]
        lon = request.form["petLon"]
Beispiel #2
0
from flask import (Flask, render_template, jsonify, request, redirect)
from models import create_classes
import simplejson
from flask_sqlalchemy import SQLAlchemy

app = Flask(__name__)

app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get(
    'DATABASE_URL', '') or "sqlite:///db.sqlite"

# Remove tracking modifications
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

db = SQLAlchemy(app)

Breweries = create_classes(db)


# create route that renders index.html template
@app.route("/")
def home():
    """
    Render the index.html template
    """
    return render_template("index.html")


def query_results_to_dicts(results):
    return simplejson.dumps(results)

Beispiel #3
0
engine = create_engine("sqlite:///space_DB.sqlite")

# reflect the tables
Base.prepare(engine, reflect=True)

# Save reference to the table
asteroid_impacts = Base.classes.asteroid_impacts
asteroid_orbits = Base.classes.asteroid_orbits
star_classification = Base.classes.star_classification
ufo_sightings = Base.classes.ufo_sightings
X_train = Base.classes.X_train

star_decipher = Base.classes.star_decipher

db = SQLAlchemy(app)
Stardecipher = create_classes(db)

# app = Flask(__name__)


#################################################
# Routes
#################################################

#### Front End ####

@app.route("/")
@app.route("/home")
def welcome():

    return render_template("index.html")
Beispiel #4
0
from sqlalchemy.ext.automap import automap_base
from sqlalchemy.orm import Session
from sqlalchemy import create_engine, func
from flask import Flask, render_template, redirect, jsonify
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
from models import create_classes

from config import username, password

#https://stackabuse.com/using-sqlalchemy-with-flask-and-postgresql/
app = Flask(__name__)
app.config[
    'SQLALCHEMY_DATABASE_URI'] = f'postgresql://{username}:{password}@localhost:5432/meteorites_db'
db = SQLAlchemy(app)
meteorites = create_classes(db)
migrate = Migrate(app, db)


@app.route('/')
def home():
    return render_template('index.html')


@app.route("/bar")
def bar():
    return render_template('barchart.html')


@app.route("/bubble")
def bubble():
Beispiel #5
0
# Connect to the local database
connection_string = f'{username}:{password}@localhost:5432/hurricanes_db'
engine = create_engine(f'postgresql://{connection_string}')

##### end test irina

from flask_sqlalchemy import SQLAlchemy
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL', '') or "sqlite:///db.sqlite"
# app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL', "postgresql://*****:*****@app.route("/jsondata")
def jsondata():
    # cursor.execute("select row_to_json(master) from master")
    # rows = cursor.fetchall()
    cursor.execute("select name, hurricane_id, year, latitude_decimal, longitude_decimal, max_wind, air_pressure, time from master")
    rows = cursor.fetchall()
    # print(rows)
    # q = ("select row_to_json(master) from master")
    # mySQL = db.executesql(q)
    # return json.dumps(mySQL)
    # # return 
    objects_list = []
    for row in rows:
Beispiel #6
0
#################################################

app = Flask(__name__)

#################################################
# Database Setup
#################################################
from flask_sqlalchemy import SQLAlchemy
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL', '') or "sqlite:///books.sqlite"

# Remove tracking modifications
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

db = SQLAlchemy(app)

Books = create_classes(db)

#################################################
# Flask Routes
#################################################

@app.route("/")
def welcome():
    """List all available api routes."""
    return render_template("index.html")

@app.route("/dashboard/")
def thedata():
    """List all available api routes."""
    return render_template("dashboard.html")    
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get(
    'DATABASE_URL', '') or "sqlite:///db.sqlite"

# Remove tracking modifications
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
"""
Using the `flask_sqlalchemy` library we'll creating our
variable `db` that is the connection to our database
"""
db = SQLAlchemy(app)
"""
from `models.py` we call `create_classes` that we will have 
a reference to the class we defined `AvatarHistory` that is 
bound to the underylying database table.
"""
AvatarHistory = create_classes(db)


# create route that renders index.html template
@app.route("/")
def home():
    """
    Render the index.html template
    """
    return render_template("index.html")


def query_results_to_dicts(results):
    """
    A helper method for converting SQLAlchemy Query objects 
    (https://docs.sqlalchemy.org/en/13/orm/query.html#sqlalchemy.orm.query.Query)
Beispiel #8
0
import os
import sqlite3
import json
from flask import (
    Flask,
    render_template,
    jsonify,
    request,
    redirect)
app = Flask(__name__)
from flask_sqlalchemy import SQLAlchemy
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL', '') or "sqlite:///db.sqlite"
# Remove tracking modifications
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)
energy = create_classes(db)
# create route that renders index.html template
@app.route("/")
def home():
    def get_tbl(tbl_name):
        database = r"db.sqlite"
        conn = sqlite3.connect(database)
        cur = conn.cursor()
        cur.execute(f"SELECT * FROM {tbl_name}")
        temp_table = cur.fetchall()
        temp_json = json.dumps(temp_table)
        #for row in consumption_table:
        #   print(row)
        return temp_json
    con_json = get_tbl("consumption")
    emi_json = get_tbl("emissions")
Beispiel #9
0
#################################################
app = Flask(__name__)

#################################################
# Database Setup
#################################################

from flask_sqlalchemy import SQLAlchemy
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get "sqlite:///db.sportsbetting.sqlite"

# Remove tracking modifications
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

db = SQLAlchemy(app)

sportsbetting = create_classes(db)

# create route that renders index.html template
@app.route("/")
def home():
    return render_template("index.html")


# Query the database and send the jsonified results
@app.route("/send", methods=["GET", "POST"])
def send():
    if request.method == "POST":
        UFC_Red_Fighter1 = request.form["Red_Corner_Fighter1"]
        UFC_Blue_Fighter1 = request.form["Blue_Corner_Fighter1"]
        UFC_Winner1 = request.form["Winner1"]
        UFC_Red_Fighter_odds1 = request.form["Red_Fighter_odds1"]
Beispiel #10
0
#################################################
# Database Setup
# The connection string to the database is listed in the URI field on Heroku Postgres (View Credentials)
# Heroku will automatically assign this URI string to the DATABASE_URL environment variable that is used within app.py
# The code that is already in app.py (below) will be able to use that environment variable to connect to the Heroku database
#################################################

from flask_sqlalchemy import SQLAlchemy
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL', '')

# Remove tracking modifications
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

db = SQLAlchemy(app)

Employment = create_classes(db)
# Real_Estate_Sales = create_classes(db)
# Covid_Closed_States = create_classes(db)


# create route that renders index.html template
@app.route("/")
def home():
    return render_template("index.html")


# Query the database and send the jsonified results
@app.route("/send", methods=["GET", "POST"])
def send():
    if request.method == "POST":
        name = request.form["petName"]
Database connection setup: Let's look for an environment variable 'DATABASE_URL'.
If there isn't one, we'll use a connection to a sqlite database.
"""
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get(
    'DATABASE_URL', '') or "sqlite:///db.sqlite"

# Remove tracking modifications
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

# Use the `flask_sqlalchemy` library we'll create our variable `db` that is the connection to our database
db = SQLAlchemy(app)
"""
From `models.py` we call `create_classes` that we will have a reference to the class
we defined `Feedback` that is bound to the underlying database table.
"""
Cuisine, Feedback = create_classes(db)


# create route that renders index.html template
@app.route("/")
def home():
    cuisine_list = [
        'African', 'American', 'British', 'Caribbean', 'Chinese',
        'East European', 'French', 'Greek', 'Indian', 'Irish', 'Italian',
        'Japanese', 'Korean', 'Mexican', 'Nordic', 'North African',
        'Pakistani', 'Portuguese', 'South American', 'Spanish',
        'Thai and South-East Asian', 'Turkish and Middle Eastern'
    ]

    return render_template("index.html", cuisine_list=cuisine_list)
Beispiel #12
0
import sqlalchemy
from sqlalchemy.ext.automap import automap_base
from sqlalchemy.orm import Session
from sqlalchemy import create_engine, func
from flask import Flask, render_template, redirect, jsonify
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
from models import create_classes

#https://stackabuse.com/using-sqlalchemy-with-flask-and-postgresql/
app = Flask(__name__, static_url_path='/static', template_folder="templates")
app.config[
    'SQLALCHEMY_DATABASE_URI'] = f'postgresql://*****:*****@localhost:5432/airbnb_db'
db = SQLAlchemy(app)
airbnb = create_classes(db)
migrate = Migrate(app, db)


@app.route('/')
def index():
    return render_template('index.html')


@app.route("/neighborhoods")
def neighborhoods():
    return render_template('neighborhoods.html')


@app.route("/heatmap")
def heatmap():
Beispiel #13
0
#################################################
# Database Setup
#################################################

from flask_sqlalchemy import SQLAlchemy
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get(
    'DATABASE_URL',
    '') or "postgresql://*****:*****@localhost/mobility2_db"

# Remove tracking modifications
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

db = SQLAlchemy(app)

Mobility = create_classes(db)


# create route that renders index.html template
@app.route("/")
def home():

    return render_template("index.html")


@app.route("/api/data")
def data():

    # df=pd.read_sql
    receiveddata = db.session.query(
        Mobility.states, Mobility.dates, Mobility.sma_retail_recreation,
Beispiel #14
0
#################################################


#################################################
# Flask Setup
#################################################
app = Flask(__name__)

app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL', '') or "sqlite:///Covid_Vision.sqlite"
engine =app.config['SQLALCHEMY_DATABASE_URI'] 
# Remove tracking modifications
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

db = SQLAlchemy(app)

Covid_Vision = create_classes(db)


@app.route("/")
def index():
    return render_template("index.html")

@app.route("/trends")
def trends():
    return render_template("trends.html")

@app.route("/choropleth")
def choropleth():
    return render_template("choropleth.html")        
    
@app.route("/api/v1.0/covid_trends")