Job board using this template Demo. Postman Collection
- Python3/pip3
- Packages listed in requirements.txt
$ pip install -r requirements.txt$ flask user create <first name> <last name> <email> <password>
$ flask applicant create <first name> <last name> <email> <password>
$ flask employer create <first name> <last name> <email> <password>
$ flask admin create <first name> <last name> <email> <password>creates the respective user
===========================================================================
$ flask applicant apply <applicantid> <joblistingid>apply the applicant with that id to the job with that job listing id
===========================================================================
$ flask applicant view_jobsshows all available jobs
===========================================================================
$ flask employer create_listing <title> <"description"> <employerId>will make a job listing tied to that employer id (the quotation marks are needed for desccription)
===========================================================================
$ flask employer view_all_applicants <employerId>will show all applicants that applied for all the jobs created by the employer with that id
===========================================================================
$ flask employer view_job_applicants <jobId>shows all applicant that applied to the job with that job id
===========================================================================
$ flask admin remove_user <id>remove user with that id
===========================================================================
$flask remove_listing <listing_id>remove listing with that id
===========================================================================
Configuration information such as the database url/port, credentials, API keys etc are to be supplied to the application. However, it is bad practice to stage production information in publicly visible repositories. Instead, all config is provided by a config file or via environment variables.
When running the project in a development environment (such as gitpod) the app is configured via default_config.py file in the App folder. By default, the config for development uses a sqlite database.
default_config.py
SQLALCHEMY_DATABASE_URI = "sqlite:///temp-database.db"
SECRET_KEY = "secret key"
JWT_ACCESS_TOKEN_EXPIRES = 7
ENV = "DEVELOPMENT"These values would be imported and added to the app in load_config() function in config.py
config.py
# must be updated to inlude addtional secrets/ api keys & use a gitignored custom-config file instad
def load_config():
config = {'ENV': os.environ.get('ENV', 'DEVELOPMENT')}
delta = 7
if config['ENV'] == "DEVELOPMENT":
from .default_config import JWT_ACCESS_TOKEN_EXPIRES, SQLALCHEMY_DATABASE_URI, SECRET_KEY
config['SQLALCHEMY_DATABASE_URI'] = SQLALCHEMY_DATABASE_URI
config['SECRET_KEY'] = SECRET_KEY
delta = JWT_ACCESS_TOKEN_EXPIRES
...When deploying your application to production/staging you must pass in configuration information via environment tab of your render project's dashboard.
wsgi.py is a utility script for performing various tasks related to the project. You can use it to import and test any code in the project. You just need create a manager command function, for example:
# inside wsgi.py
user_cli = AppGroup('user', help='User object commands')
@user_cli.cli.command("create-user")
@click.argument("username")
@click.argument("password")
def create_user_command(username, password):
create_user(username, password)
print(f'{username} created!')
app.cli.add_command(user_cli) # add the group to the cliThen execute the command invoking with flask cli with command name and the relevant parameters
$ flask user create bob bobpassFor development run the serve command (what you execute):
$ flask runFor production using gunicorn (what the production server executes):
$ gunicorn wsgi:appYou can deploy your version of this app to render by clicking on the "Deploy to Render" link above.
When connecting the project to a fresh empty database ensure the appropriate configuration is set then file then run the following command. This must also be executed once when running the app on heroku by opening the heroku console, executing bash and running the command in the dyno.
$ flask initIf changes to the models are made, the database must be'migrated' so that it can be synced with the new models. Then execute following commands using manage.py. More info here
$ flask db init
$ flask db migrate
$ flask db upgrade
$ flask db --help