From: Sam Mirazi Date: Sat, 31 May 2025 05:26:45 +0000 (-0700) Subject: file name updated X-Git-Url: https://git.josue.xyz/?a=commitdiff_plain;h=ec5b4fdba862782a15879a213510d72887a67396;p=fastapi-vs-flask%2F.git file name updated --- diff --git a/app_flask/__pycache__/flask_application.cpython-312.pyc b/app_flask/__pycache__/flask_application.cpython-312.pyc new file mode 100644 index 0000000..613afc6 Binary files /dev/null and b/app_flask/__pycache__/flask_application.cpython-312.pyc differ diff --git a/app_flask/app.py b/app_flask/app.py deleted file mode 100644 index bd4f688..0000000 --- a/app_flask/app.py +++ /dev/null @@ -1,21 +0,0 @@ -from flask import Flask, Response -import time -import webbrowser - -app = Flask(__name__) - -@app.route("/") -def home(): - time.sleep(3) # simulate slow work - html = "Hello from Flask :)" - return Response(html, mimetype="text/html") - -if __name__ == "__main__": - host = "127.0.0.1" - port = 3000 - url = f"http://{host}:{port}/" - - # Open the URL in a new browser tab - webbrowser.open_new_tab(url) - - app.run(host=host, port=port) \ No newline at end of file diff --git a/app_flask/flask_application.py b/app_flask/flask_application.py new file mode 100644 index 0000000..bd4f688 --- /dev/null +++ b/app_flask/flask_application.py @@ -0,0 +1,21 @@ +from flask import Flask, Response +import time +import webbrowser + +app = Flask(__name__) + +@app.route("/") +def home(): + time.sleep(3) # simulate slow work + html = "Hello from Flask :)" + return Response(html, mimetype="text/html") + +if __name__ == "__main__": + host = "127.0.0.1" + port = 3000 + url = f"http://{host}:{port}/" + + # Open the URL in a new browser tab + webbrowser.open_new_tab(url) + + app.run(host=host, port=port) \ No newline at end of file diff --git a/tests/__pycache__/test_flask_route.cpython-312-pytest-8.3.5.pyc b/tests/__pycache__/test_flask_route.cpython-312-pytest-8.3.5.pyc index bab6036..c1722ee 100644 Binary files a/tests/__pycache__/test_flask_route.cpython-312-pytest-8.3.5.pyc and b/tests/__pycache__/test_flask_route.cpython-312-pytest-8.3.5.pyc differ diff --git a/tests/test_flask_route.py b/tests/test_flask_route.py index 0fc0aaf..0ab89a3 100644 --- a/tests/test_flask_route.py +++ b/tests/test_flask_route.py @@ -4,14 +4,14 @@ import subprocess, time, os, signal def start_server(): # Ensure the Python interpreter can find the app_flask module. # This might require adjusting PYTHONPATH or running pytest from the project root. - proc = subprocess.Popen(["python", "-m", "app_flask.app"]) # Removed cwd=".." + proc = subprocess.Popen(["python", "-m", "app_flask.flask_application"]) # Updated module name time.sleep(1) # Increased sleep to allow server startup, especially on slower systems return proc def test_home_returns_html(): proc = start_server() try: - r = httpx.get("http://127.0.0.1:5000/", timeout=10) + r = httpx.get("http://127.0.0.1:3000/", timeout=10) assert r.status_code == 200 assert "Hello from Flask :)" in r.text # Corrected assertion finally: