vvvw/hello.py

30 lines
708 B
Python

from flask import Flask
from flask import render_template, jsonify
app = Flask(__name__)
@app.context_processor
def override_url_for():
return dict(url_for=dated_url_for)
def dated_url_for(endpoint, **values):
if endpoint == 'static':
filename = values.get('filename', None)
if filename:
file_path = os.path.join(app.root_path,
endpoint, filename)
values['q'] = int(os.stat(file_path).st_mtime)
return url_for(endpoint, **values)
@app.route('/')
def hello_world():
return render_template('hello.html')
@app.route('/hello/<name>')
@app.route("/get-data")
def get_data():
return jsonify({"a": 1, "b": 2})