...
Info |
---|
If you decide to self-host, you will need a basic understanding of Python as well as Python 3. Having familiarity with databases will also assist. |
Table of contents
Table of Contents |
---|
Setting up Postgres
We recommend using PostgreSQL for the database, as this is tested, and the recommended configuration. Installation of libpq
or an equivalent is required to sate food-server
's requirement of psycopg2
. While others will likely work as SQLAlchemy is used, we will not provide support for such configurations.
You may wish to install a tool such as pgAdmin to easily make database changes.
Info |
---|
We have no info on setting up an environment for Windows yet, you should get by with WSL |
MacOS
Assuming you use Homebrew, run the following:
Code Block | ||
---|---|---|
| ||
brew install postgresql |
To start PostgreSQL temporarily, you can run brew services run postgresql
. For more information on services via Homebrew, run brew services --help
.
...
On Debian-based distributions (i.e. Ubuntu or Linux Mint):
Code Block | ||
---|---|---|
| ||
apt install libpq-dev python3-dev postgresql postgresql-client |
For RHEL-based distributions (i.e. CentOS/Fedora):
Code Block | ||
---|---|---|
| ||
dnf install libpq-devel python3-devel postgresql-server |
For Arch Linux (Additional configuration may be required after install. Check the Arch Wiki):
Code Block | ||
---|---|---|
| ||
pacman -S postgresql-libs postgresql |
Many package managers will start PostgreSQL automatically. Typically, you can run systemctl start postgresql
to ensure this. Refer to your distribution's documentation for further information.
Creating the database
Once PostgreSQL is finished downloading, you will need to create the database.
If you installed via a package manager on either macOS or a linux based distribution, open the command line of your choice and run the below. It should be noted that in some cases you may need to run these commands with sudo
.
Code prettify | ||
---|---|---|
| ||
psql -c "CREATE USER username WITH PASSWORD 'password';"
psql -c "CREATE DATABASE database_name OWNER owner;" |
On Windows you will need to run the above, but first you will need to find the psql
binary installed to your system. In the above commands, replace psql
with the path to your psql
binary.
After all the above is complete, you will need to edit config-example.py
with your database credentials and name. Then you will need to rename config-example.py
to config.py
.
Code prettify | ||
---|---|---|
| ||
db_url = "postgresql://username:password@localhost/database_name" |
Database setup is complete!
Setting up the development environment
You'll most likely want to create a virtualenv to install things. For example:
Code Block | ||
---|---|---|
| ||
python3 -m venv virtualenv |
...
Once done, ensure you install requirements:
Code Block | ||
---|---|---|
| ||
pip3 install -r requirements.txt # Useful for reading .flaskenv. pip3 install python-dotenv |
...
Run in development mode, and enjoy!
Code Block | ||
---|---|---|
| ||
flask run --host :: --port 80 |
...