From 14402085f5c52c61909a0926c51c43653dea0c40 Mon Sep 17 00:00:00 2001 From: Sayed Abubaker Hashimi Date: Tue, 18 Mar 2025 12:53:39 +0100 Subject: [PATCH] new --- z1/Dockerfile | 20 ++++++ z1/LICENSE | 21 ++++++ z1/Procfile | 1 + z1/README.md | 62 ++++++++++++++++++ z1/__pycache__/app.cpython-38.pyc | Bin 0 -> 2028 bytes z1/app.py | 73 +++++++++++++++++++++ z1/docker-compose.postgres.yml | 25 ++++++++ z1/docker-compose.yml | 25 ++++++++ z1/manage.py | 16 +++++ z1/remove app.sh | 1 + z1/requirements.txt | 15 +++++ z1/runtime.txt | 1 + z1/start.app.sh | 2 + z1/stop.app.sh | 2 + z1/templates/index.html | 103 ++++++++++++++++++++++++++++++ z1/templates/usersdata.html | 42 ++++++++++++ 16 files changed, 409 insertions(+) create mode 100644 z1/Dockerfile create mode 100644 z1/LICENSE create mode 100644 z1/Procfile create mode 100644 z1/README.md create mode 100644 z1/__pycache__/app.cpython-38.pyc create mode 100644 z1/app.py create mode 100644 z1/docker-compose.postgres.yml create mode 100644 z1/docker-compose.yml create mode 100644 z1/manage.py create mode 100644 z1/remove app.sh create mode 100644 z1/requirements.txt create mode 100644 z1/runtime.txt create mode 100644 z1/start.app.sh create mode 100644 z1/stop.app.sh create mode 100644 z1/templates/index.html create mode 100644 z1/templates/usersdata.html diff --git a/z1/Dockerfile b/z1/Dockerfile new file mode 100644 index 0000000..317ad8e --- /dev/null +++ b/z1/Dockerfile @@ -0,0 +1,20 @@ +FROM python:3.8 + +COPY requirements.txt / + +WORKDIR / + +RUN pip3 install -r ./requirements.txt --no-cache-dir + +COPY . /app/ + +WORKDIR /app + + +ENV FLASK_APP=app.py + + +# RUN python manage.py create_db + + +CMD flask run -h 0.0.0.0 -p 1602 diff --git a/z1/LICENSE b/z1/LICENSE new file mode 100644 index 0000000..c011685 --- /dev/null +++ b/z1/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 NOMANSAEEDSOOMRO + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/z1/Procfile b/z1/Procfile new file mode 100644 index 0000000..cfc2f8f --- /dev/null +++ b/z1/Procfile @@ -0,0 +1 @@ +web: gunicorn app:app diff --git a/z1/README.md b/z1/README.md new file mode 100644 index 0000000..4e17b6f --- /dev/null +++ b/z1/README.md @@ -0,0 +1,62 @@ +# Flask-App-with-PostgreSQL-DB + +This Website is build on the Python Flask with PostgreSQL Database. Data Insertion and Fetching. + +**For Running on Local System Follow the below insturction** + +Comment the below Code in the app.py File + +'uri = os.getenv("DATABASE_URL") # or other relevant config var +if uri.startswith("postgres://"): + uri = uri.replace("postgres://", "postgresql://", 1)' + +UnComment the Below code in the app.py file + +app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///User.sqlite3" + +Run the app.py file and in the Terminal run the below commands + +pyhton + +from app import db + +db.create_all() + + +**If you are Using libraries then run the pip freeze command and for the deployment on heroku follow the below commands** + +UnComment the below Code in the app.py File + +'uri = os.getenv("DATABASE_URL") # or other relevant config var +if uri.startswith("postgres://"): + uri = uri.replace("postgres://", "postgresql://", 1)' + +Comment the Below code in the app.py file + +app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///User.sqlite3" + + +pip install gunicorn + +pip install psycopg2 + +pip freeze > requirements.txt + +Create runtime.txt and write your python version i.e python-3.7.10 + +echo web: gunicorn app:app > Procfile #creating procfile + +Create an account on heroku and also download the heroku cli + +##Write Following commands in pycharm/vscode +1. heroku login +2. heroku create "project name" +3. heroku addons:create heroku-postgresql:hobby-dev --app "project name" +4. git init +5. git add . +6. git commit -m "first commit" +7. heroku git:remote -a "project name" +8. git push heroku master +9. heroku run python +10. from app import db +11. db.create_all() diff --git a/z1/__pycache__/app.cpython-38.pyc b/z1/__pycache__/app.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bf13201495578b6402a9f15f7d8846517ad927ac GIT binary patch literal 2028 zcmZuyNpBlB6y`FU$CA9q+0mj4Fa>NCZF*>s7Lm8qs3WJbT%bI3FcxWf>{(gFZ_#1?u@bg z8MqpExXZmU1vwV=Gt3%%LNpGixc>wR-*A(_xuOBO>1T-7c>OivbuoQ7b4J;$Xk5(k z#u)P{KK&Yj%{;7`<1>7g&-DnOKPP;F-!hs7W4j2pxA`3-xh3lS?h%oH!kR^XkKgAH z&I$NUcTn)~4Md6pyR^z6=rcC$Ow;6h(-h`9#NoVWC5id!NIs4Sf!OksVHrcMsZR) zJyZSC>qkZLDwiC9VHG0Tmo?Z-)-`EpG6m!hBxm6D_S@z`o{DC15Xn5xnrossQhC2= z@U+zG_m^J9>R{i3uXC#4sLaTcpEd}Xf>S3sKR{k?2e2+P+c``^d=5A(6^dQe9=FHhqGR}H8 zg(c^}3lrHjGOJ}1Ko(#YIt3oK$Sj_(1~Iy~xcNVjQ7|>t&lW4#5w&5q<@ZoT3rjW_QpjV1-k716sHRZ@>$;;cY1jI3j=_>&!Z}6|~2N zGqT4RBg4C61ROnt`)`a+9p!V!MCi7q#^6LNRGI{n(gMrUsoZB4 z+%Bofsaym(a|=-vah{bl;!wP9o~E%XZMc}^3CNN}>O2Q-Y4J!!R|j5!6&gmo3bnSJ z(0yju4-zf!!X{t9EN%fo#0MmL)gTRA!#?pXV>9%ddXGYH_g<#;G98G?w62|ke~7|| z{8>WBzd8)2PLxK z7#+yC^b5$eDs*$}p9K6Zx + + + Register Page + + + + + + +
+ + +
+ +

Flask App with DataBase

+
+ +
+ +
+ +
+
+

Create Account

+
+
+
+
+
+

User Data Form

+
+
+
+
+ + +
+
+ + +
+ +
+ + + +
+
+ + +
+ +
+ + +
+
+
+ + +
+
+
+
+
+
+
+ + +
+ +
+ +
+ + + + +
+
+ Copyright © NSA Website +
+
+ + + + + \ No newline at end of file diff --git a/z1/templates/usersdata.html b/z1/templates/usersdata.html new file mode 100644 index 0000000..d939bd1 --- /dev/null +++ b/z1/templates/usersdata.html @@ -0,0 +1,42 @@ + + + + Bootstrap Example + + + + + + + + + +
+

User's Data

+

Fetching data from database

+ + + + + + + + + + + + + {% for user in user_data %} + + + + + + + {% endfor %} + +
IdNameEmailGender
{{user.id}}{{user.name}}{{user.email}}{{user.gender}}
+
+ + +