From a0b51bf1dcb79f96d86a6d2424625b44ae1199f2 Mon Sep 17 00:00:00 2001 From: Neon Kiwi Date: Fri, 7 Jul 2023 21:12:38 -0400 Subject: [PATCH 1/6] add experimental endpoint --- app/main.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/main.py b/app/main.py index 5aff7f2..ab032e1 100644 --- a/app/main.py +++ b/app/main.py @@ -1,6 +1,10 @@ from flask import Flask app = Flask(__name__) +@app.route("/hi/") +def hi(person): + return "Hi " + person + @app.route("/") def hello(): return "Hello from Python!" From ce0de62459823bb4ae2a7fbe8ce84dc33e2c28a3 Mon Sep 17 00:00:00 2001 From: Neon Kiwi Date: Fri, 7 Jul 2023 21:30:14 -0400 Subject: [PATCH 2/6] new fancy endpoint --- app/main.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/main.py b/app/main.py index ab032e1..925b3c9 100644 --- a/app/main.py +++ b/app/main.py @@ -5,6 +5,21 @@ def hi(person): return "Hi " + person +@app.route("/fancyhi/") +def fancyhi(person): + return f""" + +

+Fancy Greetings +

+I want to wish you a very hearty hello! +Enjoy your day, {person} +
+Enough for now! + + +""" + @app.route("/") def hello(): return "Hello from Python!" From 81d8a10c0e6f2be92cb4fabb5c6a14a6c5d21a5a Mon Sep 17 00:00:00 2001 From: Neon Kiwi Date: Sat, 8 Jul 2023 21:30:14 -0400 Subject: [PATCH 3/6] add requirements file --- requirements.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..8ab6294 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +flask \ No newline at end of file From b14720523f203639d18b8a608a3d8ceab28d8cb6 Mon Sep 17 00:00:00 2001 From: Leif Jensen Date: Sat, 8 Jul 2023 22:03:57 -0400 Subject: [PATCH 4/6] added a counting endpoint with a for statement --- app/main.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/main.py b/app/main.py index 925b3c9..5bb5398 100644 --- a/app/main.py +++ b/app/main.py @@ -20,6 +20,14 @@ def fancyhi(person): """ +@app.route("/count/") +def count(n): + ret = f"

Counting to {n}

\n
    " + for j in range(1, n + 1): + ret += f"
  • {j}
  • \n" + ret += "
\n" + return ret, 200 + @app.route("/") def hello(): return "Hello from Python!" From 7a5402222da44e8a3ac252483b58b5ff11f1117a Mon Sep 17 00:00:00 2001 From: Neon Kiwi Date: Thu, 13 Jul 2023 21:45:44 -0400 Subject: [PATCH 5/6] added factor and random endpoints --- app/main.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/main.py b/app/main.py index 5bb5398..6ca138a 100644 --- a/app/main.py +++ b/app/main.py @@ -28,6 +28,25 @@ def count(n): ret += "\n" return ret, 200 +@app.route("/factor/") +def factor(n): + ret = f"

Factors of {n}

\n
    " + for j in range(1, n + 1): + if (n/j)%1 == 0: + ret += f"
  • {int(n/j)}
  • \n" + ret += "
\n" + return ret, 200 + +@app.route("/random/") +def random(n): + ret = f"

5 random numbers from 0 to {n}

\n
    " + for j in range(5): + import random + rand = random.randint(0,n) + ret += f"
  • {rand}
  • \n" + ret += "
\n" + return ret, 200 + @app.route("/") def hello(): return "Hello from Python!" From 159968265b3ad6b9c001aa54b8976ae3bd2b6c12 Mon Sep 17 00:00:00 2001 From: Neon Kiwi Date: Thu, 13 Jul 2023 22:36:05 -0400 Subject: [PATCH 6/6] added css endpoint, links in factor endpoint, and debugger --- app/main.py | 18 ++++++++++++++---- app/profile-flask.py | 7 +++++++ 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 app/profile-flask.py diff --git a/app/main.py b/app/main.py index 6ca138a..36e1955 100644 --- a/app/main.py +++ b/app/main.py @@ -1,6 +1,9 @@ -from flask import Flask +from flask import Flask, url_for + app = Flask(__name__) +css_head = "" + @app.route("/hi/") def hi(person): return "Hi " + person @@ -30,10 +33,11 @@ def count(n): @app.route("/factor/") def factor(n): - ret = f"

Factors of {n}

\n
    " + ret = f"{css_head}

    Factors of {n}

    \n
      " for j in range(1, n + 1): if (n/j)%1 == 0: - ret += f"
    • {int(n/j)}
    • \n" + url = url_for("factor", n = int(n/j)) + ret += f"
    • {int(n/j)}
    • \n" ret += "
    \n" return ret, 200 @@ -51,5 +55,11 @@ def random(n): def hello(): return "Hello from Python!" +@app.route("/style.css") +def style(): + return """body { + background-color: lightblue; +}""" + if __name__ == "__main__": - app.run(host='0.0.0.0') + app.run(host='0.0.0.0') \ No newline at end of file diff --git a/app/profile-flask.py b/app/profile-flask.py new file mode 100644 index 0000000..2b779a3 --- /dev/null +++ b/app/profile-flask.py @@ -0,0 +1,7 @@ +from app.main import app + +app.config["PROFILE"] = True +app.config["DEBUG"] = True +app.jinja_env.auto_reload = True +app.config["TEMPLATES_AUTO_RELOAD"] = True +app.run(use_debugger = True) \ No newline at end of file