2020-09-08 16:00:47 +02:00
|
|
|
from flask import Flask
|
2020-10-09 14:59:38 +02:00
|
|
|
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():
|
2020-10-09 16:04:15 +02:00
|
|
|
return render_template('hello.html')
|
2020-09-08 16:00:47 +02:00
|
|
|
|
|
|
|
|
2020-09-24 18:21:46 +02:00
|
|
|
@app.route('/hello/<name>')
|
2020-10-09 14:59:38 +02:00
|
|
|
|
|
|
|
@app.route("/get-data")
|
|
|
|
def get_data():
|
|
|
|
return jsonify({"a": 1, "b": 2})
|