From 31084c210a1eafa5f6aa25ce3709110859ba7476 Mon Sep 17 00:00:00 2001 From: ramprasathmk Date: Mon, 9 Dec 2024 18:29:20 +0545 Subject: [PATCH] first commit --- .gitignore | 18 ++++++++++++++++++ README.md | 1 + app/main.py | 21 +++++++++++++++++++++ app/main_test.py | 17 +++++++++++++++++ requirements.txt | 9 +++++++++ 5 files changed, 66 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 app/main.py create mode 100644 app/main_test.py create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fcd44f4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,18 @@ +# Ignore specific files +.env + +# Ignore IDE files and folders +.idea +.vscode + +# Ignore python dependencies and out dir's +__pycache__ +__pycache__/* +.venv +.venv/* +.conda +.conda/* + +# Ignore py out files +*.pyo +*.pyd diff --git a/README.md b/README.md new file mode 100644 index 0000000..0cbb5f2 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# flask-github-actions-demo \ No newline at end of file diff --git a/app/main.py b/app/main.py new file mode 100644 index 0000000..ad5d845 --- /dev/null +++ b/app/main.py @@ -0,0 +1,21 @@ +from flask import Flask +from dotenv import load_dotenv +import os + +load_dotenv() + +app = Flask(__name__) + + +@app.route('/') +def return_backwards_string(random_string): + return "".join(reversed(random_string)) + + +@app.route('/get-mode') +def get_mode(): + return os.environ.get("MODE") + + +if __name__ == '__main__': + app.run(host='0.0.0.0', port=8080) diff --git a/app/main_test.py b/app/main_test.py new file mode 100644 index 0000000..a2b8d4e --- /dev/null +++ b/app/main_test.py @@ -0,0 +1,17 @@ +from main import return_backwards_string, get_mode +import unittest +import os + + +class TestMain(unittest.TestCase): + def test_return_backwards_string(self): + random_string = "This is my test string" + random_string_reversed = random_string[::-1] + self.assertEqual(random_string_reversed, return_backwards_string(random_string)) + + def test_get_env(self): + self.assertEqual(os.environ.get("MODE"), get_mode()) + + +if __name__ == '__main__': + unittest.main() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..8a58ef4 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,9 @@ +blinker==1.9.0 +click==8.1.7 +colorama==0.4.6 +Flask==3.1.0 +itsdangerous==2.2.0 +Jinja2==3.1.4 +MarkupSafe==3.0.2 +python-dotenv==1.0.1 +Werkzeug==3.1.3