update README
This commit is contained in:
parent
59ad514bd6
commit
a6bd21c03d
71
z1/README.md
71
z1/README.md
@ -1,62 +1,19 @@
|
||||
# Flask-App-with-PostgreSQL-DB
|
||||
# Introduction
|
||||
The project contains Python's Django base app, and Postgres database. The Django version 3.12 and the postgres is created from the latest image which is 14.2 at the moment. The Postgres data in mapped to a volume in docker names `dbdata`
|
||||
|
||||
This Website is build on the Python Flask with PostgreSQL Database. Data Insertion and Fetching.
|
||||
We have 4 scripts that runs the starts and deleteds the complete process.
|
||||
|
||||
**For Running on Local System Follow the below insturction**
|
||||
## Prepare script
|
||||
We get the postgres image from the docker hub repository. After that we build our Django project image.
|
||||
|
||||
Comment the below Code in the app.py File
|
||||
## Start script
|
||||
This script uses the `docker compose up` company to start all the container services in docker compose.
|
||||
|
||||
'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
|
||||
## stop script
|
||||
This script stop all the container services that are mentioned within the docker compose yaml 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()
|
||||
## remove script
|
||||
This script removes all the containers, volumes, network, and images created and utilized by the docker compose script. We are passing additional flag which does the following.
|
||||
1. `-v` this removes all the volumes utilised with the docker compose script.
|
||||
2. `--remove-orphans` this flag Remove containers for services not defined in the Compose file.
|
||||
3. `--rmi all` this removes all the images that were created by the docker compose file
|
||||
|
Loading…
Reference in New Issue
Block a user