This repository has been archived by the owner on Oct 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplenartracker.py
executable file
·68 lines (54 loc) · 1.7 KB
/
plenartracker.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# -!- coding:utf-8 -!-
import random
import re
import os
from flask import Flask
from flask_cors import CORS
from flask_migrate import Migrate
from flask_sqlalchemy import SQLAlchemy
from jinja2 import evalcontextfilter, Markup, escape
from flask_caching import Cache
app = Flask(__name__)
cache = Cache(app, config={'CACHE_TYPE': 'simple'})
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get("DATABASE_URL")
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['JSONIFY_PRETTYPRINT_REGULAR']=True
db = SQLAlchemy(app)
migrate = Migrate(app, db)
CORS(app)
@app.template_filter()
@evalcontextfilter
def nl2br(eval_ctx, value):
_paragraph_re = re.compile(r'(?:\r\n|\r|\n){2,}')
result = u'\n\n'.join(u'<p>%s</p>' % p.replace('\n', '<br>\n') \
for p in _paragraph_re.split(escape(value)))
if eval_ctx.autoescape:
result = Markup(result)
return result
@app.template_filter()
def prcolor(value):
random.seed(value)
red, green, blue = [random.randint(0, 255) for _ in range(3)]
return "rgb({}, {}, {})".format(red, green, blue)
@app.template_filter()
@evalcontextfilter
def poiemoji(eval_ctx, text):
result = []
if 'Beifall' in text:
result.append("👏")
elif "Heiterkeit" in text:
result.append("😂")
elif "Unterbrechung" in text:
result.append("⏰")
else:
result.append("🗯")
result = " ".join(result)
if eval_ctx.autoescape:
result = Markup(result)
return result
from views import *
if __name__ == "__main__":
# app.debug = os.environ.get("DEBUG", False)
# app.jinja_env.auto_reload = app.debug
# app.config['TEMPLATES_AUTO_RELOAD'] = app.debug
app.run()