shadowpage.ydns.eu

start Login

Short Flask Guidance

sudo apt update
sudo apt full-upgrade -y
sudo apt install python3 idle3
mkdir myproject
cd myproject
python3 -m venv venv
source venv/bin/activate
pip install flask
sudo nano myproject.py
Content:
from app import app
strg+s and strg+x
mkdir app
cd app
sudo nano __init__.py
Content:
strg+s and strg+x
sudo nano routes.py
Content:
strg+s and strg+x
echo "from app import app" > sudo nano myproject.py
sudo reboot
cd myproject
source venv/bin/activate
pip install flask-wtf
pip install flask-login
pip install email-validator
cd app
mkdir templates
cd templates
sudo nano index.html
Content:
strg+s and strg+x
sudo nano base.html
Content:
strg+s and strg+x
sudo nano start.html
Content:
strg+s and strg+x
cd ..
mkdir static
copy favicon.jpg and JC.jpg and shadow.jpg

Test with

cd ~/myproject/
flask run
Browser:
http://127.0.0.1:5000/
Next:
cd ~/myproject/
pip install gunicorn
sudo nano .env
Content:
strg+s and strg+x
deactivate
sudo apt-get -y install supervisor
sudo nano /etc/supervisor/conf.d/myproject.conf
Content:
strg+s and strg+x
sudo supervisorctl reload

Test with

Browser:
http://127.0.0.1:8000/
Next:
sudo apt-get -y install nginx

Test with

Browser:
http://192.168.6.10
sudo nano /etc/nginx/sites-enabled/default
Content:
strg+s and strg+x

Test with

Browser: 192.168.6.10
cd myproject
source venv/bin/activate
pip install flask-sqlalchemy
pip install flask-migrate
sudo nano config.py
Content:
strg+s and strg+x
cd app
sudo nano __init__.py
Content:
strg+s and strg+x
sudo nano models.py
Content:
strg+s and strg+x
cd ..
flask db init
flask db migrate -m "User table"
flask db migrate -m "Roles table"
flask db upgrade
Browser: 192.168.6.10/register.html
python3
from app import app, db
from app.models import User, Roles
import sqlalchemy as sa
app.app_context().push()
r = Roles(role='User')
db.session.add(r)
db.session.commit()
r = Roles(role='Admin')
db.session.add(r)
db.session.commit()
u = db.session.get(User, 1)
u.active=1
u.role=2
db.session.commit()

Impressum, Datenschutz