.. | ||
__pycache__ | ||
templates | ||
app.py | ||
docker-compose.postgres.yml | ||
docker-compose.yml | ||
Dockerfile | ||
LICENSE | ||
manage.py | ||
prepare-app.sh | ||
Procfile | ||
README.md | ||
remove-app.sh | ||
requirements.txt | ||
runtime.txt | ||
start.app.sh | ||
stop.app.sh |
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
- heroku login
- heroku create "project name"
- heroku addons:create heroku-postgresql:hobby-dev --app "project name"
- git init
- git add .
- git commit -m "first commit"
- heroku git:remote -a "project name"
- git push heroku master
- heroku run python
- from app import db
- db.create_all()