def recommend(): algo = SVD() top_n = get_top_n(predictions, n=10) # Home page @app.route("/", methods=['GET', 'POST']) def home(): """Home page of app with form""" # Create form form = ReusableForm(request.form) # On form entry and all conditions met if request.method == 'POST' and form.validate(): # Extract information username = request.form['username'] Rank1 = int(request.form['Rank1']) Rank2 = int(request.form['Rank2']) Rank3 = int(request.form['Rank3']) Rank4 = int(request.form['Rank4']) # Send template information to index.html return render_template('index.html', form=form) if __name__ == "__main__": print(("* Loading SVD model and Flask starting server..." "please wait until server has fully started")) load_surprise_model() # Run app app.run(host="0.0.0.0", port=80)
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") resp=predict() result = { 'error':False, 'product': resp["category"], "prediction": str(resp["prediction"]) } return json.dumps(result) if _name_ == "_main_": app.run(host="localhost",port=5000,debug=False)
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()
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)
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')
@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} ) return jsonify(station_list) @app.route('/api/v1.0/<start>/<end>') def start_end_stations(start, end): weather_rows = engine.execute(""" SELECT round(avg(m.tobs), 2) as avg_temp, round(min(m.tobs), 2) as min_temp, round(max(m.tobs), 2) as max_temp FROM Measurement m WHERE m.date BETWEEN '{}' AND '{}' ORDER BY 1 """.format(start_date, end_date)).fetchall() return {"data": [dict(x) for x in weather_rows]} app.run(debug=True)
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)
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)
def consensus(): replaced = blockchain.resolve_conflicts() if replaced: response = { 'message': 'Our chain was replaced', 'new_chain': blockchain.chain } else: response = { 'message': 'Our chain is authoritative', 'chain': blockchain.chain } return json(response), 200 if __name__ == '__main__': from argparse import ArgumentParser parser = ArgumentParser() parser.add_argument('-p', '--port', default=5000, type=int, help='port to listen on') args = parser.parse_args() port = args.port app.run(host='0.0.0.0', port=port)
from Flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "Hello World!" if __name__ == "__main__": app.run()
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)
return greet_format # Create a function named greet_admin which redirect the request to the hello path with param of 'Master Admin!!!!' # and assign to the route of ('/greet-admin') @app.route('/admin') def admin(): return redirect(url_for('error')) # Rewrite a function named greet which which uses template file named `greet.html` under `templates` folder # and assign to the dynamic route of ('/<name>') @app.route('/<username>') def greet(username): return render_template('greet.html', name=username) # Create a function named list10 which creates a list counting from 1 to 10 within `list10.html` # and assign to the route of ('/list10') @app.route('/list10') def list10(): return render_template('list10.html') # Create a function named evens which show the even numbers from 1 to 10 within `evens.html` # and assign to the route of ('/evens') @app.route('/evens') def evens(): return render_template('evens.html') # Add a statement to run the Flask application which can be reached from any host on port 80. if __name__ == __main__: app.run(debug=True) app.run('0.0.0.0', port=80)
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)
#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 )
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)
from Flask import Flask, render_template server = Flask(__name__) @server.route("/") def home(): return render_template("data.html") if __name__ == "__main__": server.run()