Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

brandon-wallace/fstack-forum

Repository files navigation

FStack Forum

A Forum built with Python, Flask, Flask Blueprints, Flask-SQLAlchemy, and Postgresql.

Screenshots

screenshot1


screenshot2


screenshot3


screenshot4


screenshot6


Installation

Clone repository.

$ git clone git@github.com:brandon-wallace/fstack-forum.git
$ cd fstack-forum/

Create a .env file. Add the following environmental variables:

$ vim .env
FLASK_ENV=development
FLASK_APP=run.py
DATABASE_URI='postgresql://<username>:<password>@<hostname>:<port>/<database_name>'
DEV_DATABASE_URI='postgresql://<username>:<password>@<hostname>:<port>/<dev_database_name>'
SECRET_KEY=<your_secret_key>
SECURITY_PASSWORD_SALT=<your_password_salt>

To connect to a local SMTP server add this to the .env file.

MAIL_SERVER='localhost'
MAIL_PORT=25
MAIL_USERNAME=""
MAIL_PASSWORD=""
MAIL_DEFAULT_SENDER="no-reply@<yourdomain.com>"

To use Gmail as an SMTP server add this to the .env file.

MAIL_SERVER='smtp@gmail.com'
MAIL_PORT=465
MAIL_USERNAME="<your_gmail_username@gmail.com>"
MAIL_PASSWORD="<your_gmail_password>"
MAIL_DEFAULT_SENDER=("<Your gmail username>", "<your_gmail_username@gmail.com>")

Initialize and activate virtual environment.

$ pipenv shell

Install dependencies.

$ pipenv install
$ pipenv install flask-debugtoolbar --dev

Install PostgreSQL

Install PostgreSQL

Create a database.

$ sudo su - postgres
$ psql
# CREATE DATABASE fstackforum.db
# CREATE DATABASE fstackforumdev.db
# \q

Create tables in the database.

$ python3 
>>> from application.models import User, Post, Comment
>>> from application import db, create_app
>>> app = create_app()
>>> app.app_context().push()
>>> db.create_all()
# Output
[...]
2020年07月05日 13:50:21,831 INFO sqlalchemy.engine.Engine 
CREATE TABLE "user" ( 
 id SERIAL NOT NULL, 
 username VARCHAR(20) NOT NULL, 
 email VARCHAR(120) NOT NULL, 
 email_confirmed BOOLEAN NOT NULL, 
 email_confirmed_on TIMESTAMP WITHOUT TIME ZONE,
 image_file VARCHAR(20) NOT NULL, 
 password VARCHAR(60) NOT NULL, 
[...]
>>> exit()

Start the development server.

$ flask run -h 127.0.0.1 -p 5000

Run application as a service.

Create a systemd service to run application.

$ vim /etc/systemd/system/fstackforum.service 
[Unit]
Description=Use Guicorn to run fstackforum.
After=network.target
[Service]
User=<your_username>
Group=<group_name> 
WorkingDirectory=/path/to/fstackforum
ExecStart=/path/to/gunicorn --workers 3 --bind unix:/path/to/fstackforum/fstackforum.sock wsgi:app 
[Install]
WantedBy=multi-user.target

Start the service.

$ sudo systemctl enable fstackforum.service
$ sudo systemctl start fstackforum.service

Troubleshooting

Add logging to Gunicorn. Change the systemd file from this.

ExecStart=/path/to/gunicorn --workers 3 --bind unix:/path/to/fstackforum/fstackforum.sock wsgi:app 

To this:

ExecStart=/path/to/gunicorn --workers 3 --bind unix:/path/to/fstackforum/fstackforum.sock wsgi:app --error-logfile /path/to/fstackforum/gunicorn-error.log --log-level debug

Check the systemd service.

$ sudo systemctl status fstackforum.service
$ journal -xe

License

This project is licensed under the GPL-3.0 License.

About

A Forum built with Python, Flask, Flask Blueprints, Flask-SQLAlchemy, and Postgresql.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

AltStyle によって変換されたページ (->オリジナル) /