File: app.py

package info (click to toggle)
debugpy 1.8.19%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,452 kB
  • sloc: python: 14,840; sh: 185; makefile: 33
file content (47 lines) | stat: -rw-r--r-- 1,013 bytes parent folder | download | duplicates (3)
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
import os
from flask import Flask
from flask import render_template


app = Flask(__name__)
exiting = False


@app.route("/")
def home():
    content = "Flask-Jinja-Test"
    print("break here")  # @bphome
    return render_template("hello.html", title="Hello", content=content)


@app.route("/handled")
def bad_route_handled():
    try:
        raise ArithmeticError("Hello")  # @exc_handled
    except Exception:
        pass
    return render_template("hello.html", title="Hello", content="Flask-Jinja-Test")


@app.route("/unhandled")
def bad_route_unhandled():
    raise ArithmeticError("Hello")  # @exc_unhandled
    return render_template("hello.html", title="Hello", content="Flask-Jinja-Test")


@app.route("/badtemplate")
def bad_template():
    return render_template("bad.html", title="Hello", content="Flask-Jinja-Test")


@app.route("/exit")
def exit_app():
    global exiting
    exiting = True
    return "Done"


@app.teardown_request
def teardown(exception):
    if exiting:
        os._exit(0)