To see all endpoints and structure of api requests read API_README.md
- Python 3+
- Flask framework
- SQLAlchemy, flask-sqlalchemy - for Database ORM.
- Bcrypt - for password hashing.
- Alembic - for DB migrations.
- WTForms - for flask form.
- all dependencies you can see in requirements.txt ...
- You need mysql docker image, for downloading it execute:
docker pull mysql
- Clone the Project
- Build the project with:
docker-compose build
- First launch with:
docker-compose up
docker-compose start
docker-compose stop
- Clone the Project
- Setup Environment
pip install pipenv
- Install dependencies
pip install -r requirements.txt
- Initialization database and execution migrations
python manage.py runserver db init
python manage.py runserver db migrate
python manage.py runserver db upgrate
After these commands foldermigrations
will be created. It includes database migrations and versions (executepython manage.py runserver db -?
to see all commands with database) - Run server
python manage.py runserver -h 0.0.0.0 -p 5000
- You can start the server with different options. To see them execute:
python manage.py runserver -?
App is accessed on http://0.0.0.0:5000/
-
Download nginx
brew install nginx
-
Create sites-available and sites-enabled directories
mkdir /usr/local/etc/nginx/sites-available
mkdir /usr/local/etc/nginx/sites-enabled
-
Create app.conf file in sites-available
cd /usr/local/etc/nginx/sites-available
vi app.conf
server {
listen 8000; # port with our app
server_name app; # host with our app
location / {
include uwsgi_params;
uwsgi_pass unix:/Users/mac/Desktop/messenger/flask-uwsgi.sock; # path to your app directory (your can create socker in every directory, but it is better to do it in app directory)
} # socket file will be created autimatically
location /static {
root /Users/mac/Desktop/messenger; # path to your static directory
}
}
- Connect app.conf to nginx.conf file
vi /usr/local/etc/nginx/nginx.conf
add two string in nginx.conf
...
http {
include /etc/nginx/conf.d/*.conf; #
include /usr/local/etc/nginx/sites-enabled/*.conf; # path to sites-enabled dir
...
to check conf run nginx -t
- Create symbolic link
ln -s /usr/local/etc/nginx/sites-available/app.conf /usr/local/etc/nginx/sites-enabled
- Start and reload nginx
nginx
nginx -s reload
- Install uwsqi in our app directory( in virtual env)
pip install uwsqi
- Create ini file uwsgi and change it for you preference
- Run uwsgi
uwsgi uwsgi.ini
https://medium.com/@ekwinder/setting-up-uwsgi-with-nginx-on-macos-for-python-web-apps-25edf4edab19
https://medium.com/faun/deploy-flask-app-with-nginx-using-gunicorn-7fda4f50066a