https://github.com/cdgriffith/flaskbootstrap
Generic starting point for a standard flask project
https://github.com/cdgriffith/flaskbootstrap
Last synced: 9 months ago
JSON representation
Generic starting point for a standard flask project
- Host: GitHub
- URL: https://github.com/cdgriffith/flaskbootstrap
- Owner: cdgriffith
- License: mit
- Created: 2018-05-06T19:44:33.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-31T04:16:58.000Z (over 7 years ago)
- Last Synced: 2025-03-24T20:21:22.434Z (10 months ago)
- Language: Python
- Size: 10.7 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FlaskBootstrap
Generic starting point for a standard flask project
Designed for:
* Python 3.6+
* Linux
Run the setup to rename everything to your own project name.
```bash
python -m venv venv
source venv/bin/activate
pip install reusables
python project_setup.py
```
Create your own config file at .config.yaml
Should contain the following items:
```yaml
env: production
host: 0.0.0.0
port: 8080 # Should match the one in .nginx
session_secret: bad_secret # make real one with os.urandom(32).hex()
```
Run the project:
```bash
pip install -r requirements.txt
python -m project_name
```
## Deploy for project_name
As on Ubuntu 18.04
As root:
```
apt update
apt install nginx python3-venv python3-pip apache2-utils -y
mkdir /var/log/
addgroup
adduser
htpasswd -c /etc/nginx/.htpasswd
# make the three directories of the current live site (src), backup duirng deploy (backup) and staged files for deployment (staging)
mkdir -p /opt/ /opt//src /opt//staging /opt//backup
# Copy project to /opt//src/
chown -R : /opt/
sudo -u bash -c "python3 -m venv /opt//venv"
sudo -u bash -c "/opt//venv/bin/pip install -r /opt//src/requirements.txt --no-cache"
# copy SSL certificate to /etc/ssl/certs/.crt
# copy SSL key to /etc/ssl/private/.key
cp /opt//src/.nginx /etc/nginx/sites-available/
chown root:root /etc/nginx/sites-available/
chmod 0644 /etc/nginx/sites-available/
ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/
rm /etc/nginx/sites-enabled/default
cp /opt//src/.service /etc/systemd/system/.service
chown root:root /etc/systemd/system/.service
chmod 0755 /etc/systemd/system/.service
systemctl daemon-reload
systemctl enable /etc/systemd/system/.service
systemctl start .service
# Modify /etc/nginx/nginx.conf, add under http
# client_max_body_size 2M;
service nginx restart
```