Flaskex with PostgreSQL

Demo

This directory is a serverless example of Flaskex, ready to deploy on ZEIT Now.

Features

  • Encrypted user authorizaton
  • Database initialization
  • New user signup
  • User login/logout
  • User settings
  • Bulma CSS framework

To get started with this project yourself, use the following command from Now CLI:

$ now init flaskex-postgresql

Alternatively, create a project, and Git repository, with this example template using the ZEIT dashboard.

Once initialized locally, you will see several .py files which each correspond to a route in defined in the now.json configuration file. Each .py file is an input to the Python Builder which emits a corresponding Lambda for each file.

You will need to add a couple of secrets before deploying.

$ now secrets add flaskex-db-uri 'postgresql+pg8000://username:password@pgsql.example.com/database' 

This example uses postgresql but you can use any engine supported by sqlalchemy.

$ now secrets add flaskex-secret-key '_5#y2LF4Q8z*Uz]' 

This secret key is used by Flask when signing secrets. This can be a randomly generated string.

To deploy this application, with Now installed, run the following from your terminal:

$ now

Alternatively, your new Flaskex app can be automatically deployed and aliased using Now for GitHub or Now for GitLab. Pushing these files to a new repository with a now.json file in the root, and with either Now for GitHub or Now for GitLab configured for that repository, means your site will be automatically deployed for every push and pull/merge request, and aliased for every push to the default branch!

Included In This Starter

This starter project includes:

  • A /index.py file that responds to the / route.
  • A /signup.py file that responds to the /signup route.
  • A /settings.py file that responds to the /settings route.
  • A /logout.py file that responds to the /logout route.
  • A requirements.txt file that installs dependencies such as Flask, SQLAlchemy, bcrypt, pg8000 (PostgreSQL driver)
  • A generated Pipfile.lock that ensures exact versions of dependencies to avoid the risk of automatically upgrading packages that depend upon each other and breaking your project dependency tree.

Resources

For more resources on how to configure your new Flask app to do more with Now or to deploy any other kind of application, see the following:

For more information on Flask itself, see their documentation.