-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapper.py
46 lines (35 loc) · 1.06 KB
/
apper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import os
from flask import Flask, render_template, url_for, jsonify
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
from config import Config
app = Flask(__name__)
app.config.from_object(Config)
db = SQLAlchemy(app)
migrate = Migrate(app, db)
from models import Questions
@app.route('/')
def index():
resp = Questions.query.all()
# return f'{resp}'
questions = []
for item in resp:
questions.append(item.question)
# return jsonify(questions)
return f'{questions}'
# SNIPPET FOR CAESH #
@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)
# SNIPPET FOR CAESH #
if __name__ == "__main__":
app.run(debug=True)
# app.run()