Coder Social home page Coder Social logo

jrusso1020 / flask-api-template Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 3.0 19 KB

Template for flask api backend using Postgres as the database

Python 98.19% Mako 1.81%
flask-api-backend postgres flask-template flask-bootstrap flask-restful flask-api

flask-api-template's Introduction

flask-api-template

Backend Flask API template using Postgres

This README describes how to setup the environment and run the flask server

Based on the template found here https://github.com/spchuang/DoubleDibz-tutorial/tree/master/FINAL

Installing Dependencies

This has been developed using python 3.6. You are recommended to use Anaconda or virtualenv to hold the dependencies to not pollute the system installs.

To install all packages and clean up the directory afterwards do

python setup.py install
python setup.py clean

Environment Variables

This template uses environment variables to store the SECRET_KEY value, DATABASE_URL, and TEST_DATABASE_URL. So make sure you create a .env file in the root directory and populate those values, you can see them being used in the app/config.py file.

Postgres

Install Postgres

This can be accomplished on mac using homebrew with the command

brew install postgres

Running Postgres in the Foreground

Run postgres before doing the following commands either in the foreground or background To run in the foreground use the command on mac

postgres -D /usr/local/var/postgres

Open postgres user:

sudo su - postgres

Open PSQL using:

psql

if the above command does not work then do

sudo -u username psql postgres

where username is your username

Create a database user

create role XXX with createdb login password 'XXX';

Create development database

To create the development database and test database run the following

CREATE DATABASE XXX OWNER XXX;
CREATE DATABASE XXX OWNER XXX;

Running Postgres in the Background and Restarting

If you would like to keep postgres running in the background and restart it use the command

sudo service postgresql restart

Creating the Database Tables

To create the database tables you must run the following command in the root directory

python manage.py initdb

Running the Application

To run the application you must run the following command in the root directory

python manage.py run

Testing the Application

To test the application you must run the following command in the root directory

nose2

flask-api-template's People

Contributors

jrusso1020 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.