web-app / app.py
BaoLoi2003's picture
Update information
3f5636b verified
Raw History Blame Contribute Delete
923 Bytes
import os
# from flask import Flask
from flask import (Flask, redirect, render_template, request,
send_from_directory, url_for)
app = Flask(__name__)
# @app.route('/')
# def hello():
# return "Hello from Flask (in Docker)"
@app.route('/')
def index():
print('Request for index page received')
return render_template('index.html')
@app.route('/favicon.ico')
def favicon():
return send_from_directory(os.path.join(app.root_path, 'static'),
'favicon.ico', mimetype='image/vnd.microsoft.icon')
@app.route('/hello', methods=['POST'])
def hello():
name = request.form.get('name')
if name:
print('Request for hello page received with name=%s' % name)
return render_template('hello.html', name = name)
else:
print('Request for hello page received with no name or blank name -- redirecting')
return redirect(url_for('index'))