vvvw/hello.py

30 lines
708 B
Python
Raw Normal View History

2020-09-08 16:00:47 +02:00
from flask import Flask
from flask import render_template, jsonify
2020-09-08 16:00:47 +02:00
app = Flask(__name__)
2020-09-08 20:31:48 +02:00
@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)
2020-09-08 16:00:47 +02:00
@app.route('/')
def hello_world():
return render_template('hello.html')
2020-09-08 16:00:47 +02:00
@app.route('/hello/<name>')
@app.route("/get-data")
def get_data():
return jsonify({"a": 1, "b": 2})