def create_app() -> Flask:
    flask_app = Flask('ml_api')

    from api_controller import prediction_app
    flask_app.register_blueprint(prediction_app)

    return flask_app
示例#2
0
from Flask import Flask
from flask.ext.social import Social
from flask.ext.social.datastore import SQLAlchemyConnectionDatastore
import config

app = Flask(__name__)
db = SQLAlchemy(app)

app.config['SOCIAL_FOURSQUARE'] = {
	'consumer_key': config.SQ_CLIENT_ID,
    'consumer_secret': config.SQ_CLIENT_SECRET
}


import pip
import os
import subprocess as sub


sub.call(["sudo", "apt-get", "install", "python3-flask"])

from Flask import Flask, render_template

app = Flask(__name__)

@app.route('/')
  def HelloWorld():
      return 'Hello world'

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

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

@app.route('/Imageslog')
  def imageslog():
      return render_template('ImagesLog.html')



  if __name__ == '__main__':
      app.run(debug=True, host='0.0.0.0')
示例#4
0
from Flask import Flask, render_template, redirect, url_for, session

app = Flask(__name__)


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


@app.route("/login", methods=["GET", "POST"])
def login():
    if request.method == "GET":
        return render_template("login.html")
    else:
        return "HI"


if __name__ == "__main__":
    app.debug = True
    app.secret_key = "ping"
    app.run(port=8000)
示例#5
0
from Flask import Flask 
app = Flask(__name__)

@app.route('/<int:userID>') 
def hello(userID):
    return 'The user ID is: {}'.format(escape(userID))

@app.route('/') 
def hello_world():
    return 'Hello, World!'

@app.route('/index') 
def index():
    return 'Index, Page'

@app.route('/test1') 
def test():
    return 'Test Page'


if __name__ == '__main__':
    app.debug = True
    app.run(debug=True, host='127.0.0.1', port=8000)
示例#6
0
from Flask import Flask, render_template

app = Flask(__name__, static_folder="../static/dist", template_folder="../static")

@app.route("/")

def index():
    return render_template("index.html")

@app.route("/hello")

def hello():
    return "Hello World!"

if __name__ == "__main__":
    app.run()
示例#7
0
    def valid_proof(last_proof, proof, last_hash):
        """
        Validates the Proof
        :param last_proof: <int> Previous Proof
        :param proof: <int> Current Proof
        :param last_hash: <str> The hash of the Previous Block
        :return: <bool> True if correct, False if not.
        """

        guess = f'{last_proof}{proof}{last_hash}'.encode()
        guess_hash = hashlib.sha256(guess).hexdigest()
        return guess_hash[:4] == "0000"


# Instantiate the Node
app = Flask(__name__)

# Generate a globally unique address for this node
node_identifier = str(uuid4()).replace('-', '')

# Instantiate the Blockchain
blockchain = Blockchain()


@app.route('/mine', methods=['GET'])
def mine():
    # We run the proof of work algorithm to get the next proof...
    last_block = blockchain.last_block
    proof = blockchain.proof_of_work(last_block)

    # We must receive a reward for finding the proof.
示例#8
0
from Flask import Flask, render_template, redirect, url_for, session

app = Flask(__name__)

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

@app.route("/login", methods = ["GET","POST"])
def login():
    if request.method == "GET":
        return render_template("login.html")
    else:
        return "HI"

if __name__ == "__main__":
    app.debug = True
    app.secret_key = "ping"
    app.run(port=8000)
from Flask import Flask

from settings import *

app = Flask(__name__)
app.config["MONGODB_SETTINGS"] = MONGODB_SETTINGS
app.config["SECRET_KEY"] = SECRET_KEY

if __name__ == '__main__':
    app.run()
示例#10
0
#Nikhil Padhye
#MyWebsite.py
from Flask import Flask
app = Flask(__name__)

@app.route(“/“)
def greetinb():
	return (“Hi, this is Nikhil's website!”)

if __name__ == (__main__):
	app.run(
	host = “0.0.0.0”, 
	port = 5000
)
示例#11
0
from Flask import Flask
app=Flask(__name__);
app.route('/');

def index():
return 'Hello World';
示例#12
0
from Flask import Flask, render_template, request

app = Flask(__name__)

APPLICATION_NAME = "Mancala"


@app.route('/play')
def play():
    pass


if __name__ == '__main__':
    app.secret_key = 'super_secret_key'
    app.debug = True
    app.run(host='0.0.0.0', port=8080)
示例#13
0
from Flask import Flask, render_template

app = Flask(_name_)


@app.route('/')
def home():
    title = "Home Page"
    pageHeader = "This is the home page"
    return render_template("home.html", title=title, header=pageHeader)
示例#14
0
from Flask import Flask, render_template

server = Flask(__name__)


@server.route("/")
def home():
    return render_template("data.html")


if __name__ == "__main__":
    server.run()
示例#15
0
from Flask import Flask
from Flask import render_template

app = Flask(__name__)


@app.route('/')
def hello_world():
    greeting = "Hello World"
    render = render_template('index.html', greet=greeting)
    return render


if __name__ == "__main__":
    app.run()
示例#16
0
from Flask import Flask, render_template, url_for, redirect, request

import csv

app = Flask(__name__)

def parse_inbound():
    get_csv = open('logs/inbound.csv', 'rt')
    get_data = csv.DictReader(get_csv)
    data_list = list(get_data)
    return data_list

def get_income():
    total_income = 0
    with open('logs/income.csv', 'r') as inc:
        inc_read = csv.reader(inc, delimiter=',')
        next(inc_read)  # ignore header
        for row in inc_read:
            total_income += int(row[0])
    return total_income

@app.route('/')
def index():
    object_list = parse_inbound()
    return render_template('index.html', object_list=object_list)

if __name__ == '__main__':
    app.run(host='192.168.43.145', post=8888, debug=True, use_reloader=True)
示例#17
0
from Flask import Flask, render_template, request
from flask_sqlalchemy import SQLAlchemy

app = Flask(__name__)
#ENV = 'dev'
ENV = 'prod'

if ENV == 'dev':
    app.debug = True
    app.config[
        'SQLALCHEMY_DATABASE_URI'] = 'postgresql://*****:*****@localhost/databasename'
else:
    app.debug = False
    app.config['SQLALCHEMY_DATABASE_URI'] = open('psql_db.txt').read()

app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

db = SQLAlchemy(app)


class database(db.Model):
    __tablename__ = 'data'
    id = db.Column(db.Integer, primary_key=True)
    column1 = db.Column(db.String(200), unique=True)
    column2 = db.Column(db.String(200), unique=True)

    def __init__(self, column1, column2):
        self.column1 = column1
        self.column2 = column2

示例#18
0
#Import Flask modules
from Flask import Flask
#Create an object named app 
app = Flask(__name__)

# Create a function named home which returns a string 'This is home page for no path, <h1> Welcome Home</h1>' 
# and assign route of no path ('/')
@app.route('/')
def home():
    return 'This is home page for no path, <h1> Welcome Home</h1>'
# Create a function named about which returns a formatted string '<h1>This is my about page </h1>' 
# and assign to the static route of ('about')
@app.route('/about')
def about():
    return'<h1>This is my about page </h1>'
# Create a function named error which returns a formatted string '<h1>Either you encountered an error or you are not authorized.</h1>' 
# and assign to the static route of ('error')
@app.route('/error')
def error():
    return '<h1>Either you encountered an error or you are not authorized.</h1>'

# Create a function named hello which returns a string of '<h1>Hello, World! </h1>' 
# and assign to the static route of ('/hello')
@qpp.route('/hello')
def hello():
    return '<h1>Hello, World! </h1>'
# Create a function named admin which redirect the request to the error path 
# and assign to the route of ('/admin')
@app.route('/admin')
def admin():
    return redirect(url_for('error'))
def create_app():
    app = Flask(__name__)

    return app
示例#20
0
from Flask import Flask, render_template, redirect, url_for, request, jsonify, abort, request
from Flask_Sqlalchemy import SQLAlchemy
from form import StudentForm

app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///site.db'
db = SQLAlchemy(app)


class Student(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(50), nullable=False)
    physics = db.Column(db.Integer)
    maths = db.Column(db.Integer)
    chemistry = db.Column(db.Integer)


@app.route('/', methods=['GET', 'POST'])
def add_results():
    form = StudentForm()
    if form.validate_on_submit():
        student = Student(
            name=form.name.data,
            physics=form.physics.data,
            maths=form.maths.data,
            chemistry=form.chemistry.data,
        )
        db.session.add(student)
        db.session.commit()
        return redirect(url_for('add_results'))
示例#21
0
from Flask import Flask, json
import datetime as dt
import sqlalchemy
from dbsetup import session, Measurement, Station, engine

app = Flask(__name__)

@app.route('/api/v1.0/precipitation/')
def precipv1():
    weather_rows = engine.execute("""
    SELECT m.date, round(avg(m.tobs), 2) as temp
    FROM Measurement m
    WHERE strftime("%Y", m.date) = '2017'
    GROUP BY 1
    ORDER BY 1
    """).fetchall()
    vals = 'k:v for k,v in weather_rows}
    return jsonify(vals)

@app.route('/api/v1.0/stations/')
def stations_route():
    station_list = {}
    station_list['data'] = []

    for row in session.query(Station):
        station_list['data'].append(
            {"id": row.id,
            "station": row.station,
            "lat": row.latitude,
            "lng": row.longitude,
            "elev": row.elevation}
示例#22
0
from Flask import Flask, jsonify
from flaskext.mysql import MySQL

app = Flask(__name__)
mysql = MySQL()

# MySQL configurations
app.config['MYSQL_DATABASE_USER'] = '******'
app.config['MYSQL_DATABASE_PASSWORD'] = '******'
app.config['MYSQL_DATABASE_DB'] = 'testdb'
app.config['MYSQL_DATABASE_HOST'] = 'localhost'


mysql.init_app(app)


@app.route('/')

def get():
        cur = mysql.connect().cursr()
        cur.execute('''select * from testdb.test_table''')
        r = [dict((cur.description[i][0]
示例#23
0
from Flask import Flask
from flask.ext.social import Social
from flask.ext.social.datastore import SQLAlchemyConnectionDatastore
import config

app = Flask(__name__)
db = SQLAlchemy(app)

app.config['SOCIAL_FOURSQUARE'] = {
    'consumer_key': config.SQ_CLIENT_ID,
    'consumer_secret': config.SQ_CLIENT_SECRET
}
from Flask import Flask
app = Flask(__name__)


@app.route("/")
def hello():
    return "Hello World!"

if __name__ == "__main__":
    app.run()
示例#25
0
from Flask import Flask,request,redirect,render_template

app = Flask(__name__)#cretes a Flask app
app.config[DEBUG] = True

tasks = []
@app.route('/todos',methods=['POST','GET'])
def todos():
    if request.method='POST':
        task = request.form['task'
        tasks.append(task)]

    return render_template('todos.hml',title="TODOs",tasks=tasks)

app.run()
示例#26
0
文件: main.py 项目: DianaNB/MFM-LCFP
from Flask import Flask

app = Flask(__name__)
app.config['DEBUG'] = True


@app.route("/")
def index():
    return "Hello World"


app.run()
示例#27
0
from Flask import Flask

app = Flask(__name__)
示例#28
0
#Importing Flask
from Flask import Flask


def home():
    return "Hello"


app = Flask(__main__)

if __main__ == "__main__":
    app.run()
示例#29
0
    def make_server(self):
        app = Flask(__name__)

        @app.route("/queue")
示例#30
0
文件: app.py 项目: TomMcB/submissions
from Flask import Flask, render_template, request, session, redirect, url_for
##import utils

app = Flask(__name__)

@app.route("/")
@app.route("/home")
@app.route("/home/")
def home():
    if "logged_in" in session and session["logged_in"]:
        return render_template("home.html")
    else:
        return redirect(url_for("login"))

@app.route("/login", methods = ["GET","POST"])
@app.route("/login/", methods = ["GET","POST"])
def login():
    if request.method == "GET":
        if "logged_in" in session and session["logged_in"]:
            return render_template(url_for("home"))
        else:
            return render_template("login.html")
    else:
        return "not get"

    
if __name__ == "__name__":
    app.debug = True
    app.run(host = "0.0.0.0", port=8000)
示例#31
0
文件: edge.py 项目: JaisriA/jaisri306







from Flask import Flask, request, jsonify, render_template, send_file
import json
import base64
ihportos
from flask_cors import CORS

from predictor import predict
app = Flask (_name_, template_folder='templates')
CORS(app, resources={r" /api/*": {"origins": "*}})

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

@app.route ('/assets /<path:path>')
def serve_static (path):
    return send_file ("assets /"+path)
@app.route (' /api /image_upload',methods=["POST"])
def ImageUpload():
    if "image" in (request.files):
                                  file=request.files["image"]
file.save("image.jpeg")
示例#32
0
# Import Dependecies 
from Flask import Flask, render_template, redirect
from flask_pymongo import flask_pymongo
import scrape_mars
import os

# Flask app

app = Flask(__name__)

#Use flask_pymongo to set the connection
app.config["Mongo_UR"] = os.environ.get('authentication')
mongo = PyMongo

#Use flask_pymongo to set up local connection

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

    # Find data 
    mars_info = mongo.db.mars_info.find_one()

    return render_template("index.html", mars_info=mars_info)


    #Route that will use the scrape function
    @app.route("/scrape")
    def scrape():

    #Run the scraped functions
    mars_info = mongo.db.mars_info
示例#33
0
from Flask import Flask, render_template, request
from wtforms import Form, TextField, validators, SubmitField, IntegerField
import random
from surprise import dump, SVD
import pickle
from collections import defaultdict
import pandas as pd

# Create app
app = Flask(__name__)


class ReusableForm(Form):
    """User entry form for entering game rankings for recommendations"""

    Userdf = pd.DataFrame.from_csv('UserReviews.csv')
    Top30 = Userdf.Game_Title.value_counts().index[0:30]
    GamestobeRanked = random.sample(list(Top30), k=4)

    # Username
    username = TextField("Enter a username:",
                         validators=[validators.InputRequired()])
    print('\n Consider the following games: \n')
    print(GamestobeRanked[0] + '\n')
    print(GamestobeRanked[1] + '\n')
    print(GamestobeRanked[2] + '\n')
    print(GamestobeRanked[3] + '\n')
    print(
        ' \nPlease rank your interest in these games from 1 to 4. 1 is the best, and 4 is the worst:\n'
    )
示例#34
0
from Flask import Flask, render template, url_for, request, session, redirect
from flask.ext.pymongo import PyMongo
import bcrypt

app = Flask(__name__)

mongo = PyMongo(app)

@app.route('/')
def index():
    if username in session:
        return 'You are logged in as ' +session['username']

    return render_template[index.html]

app.route('/login', methods=['POST'])
def login():
    users = mongo.db.users
    login_user = users.find_one({'name': request.form['username']})

    if login_user:
        if bcrypt.hashpw(request.form['pass'].encode('utf-8'), login_user['password'].encode('utf-8') == login_user['password'].encode('utf-8')):
            session['username'] = request.form['username']
            return redirect(url_for('index'))

    return 'Invalid username/password combination'

app.route('/register', methods=['POST', 'GET'])
def register():
    if request.method == 'POST':
        users = mongo.db.users