diff --git a/app/main.py b/app/main.py index 5aff7f2..36e1955 100644 --- a/app/main.py +++ b/app/main.py @@ -1,9 +1,65 @@ -from flask import Flask +from flask import Flask, url_for + app = Flask(__name__) +css_head = "" + +@app.route("/hi/") +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("/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("/factor/") +def factor(n): + ret = f"{css_head}

Factors of {n}

\n
    " + for j in range(1, n + 1): + if (n/j)%1 == 0: + url = url_for("factor", n = int(n/j)) + 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!" +@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 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