Skip to content

Installation

Marcos Bomfim edited this page Jul 23, 2021 · 34 revisions

Installation

The python version for install nanobrok-server is high python 3.6 (I recommand this version). If you just want to use the tool, you can install Nanobrok-server in a few different ways according to what you find easiest.

Virtualenv

The nanobrok-server can be to install easily using the virtualenv, you should be install the virtualenv your python version.

Installing virtualenv

Installing a virtualenv is done using pip, Python's package manager. follow a google tutorial how to install pip your Operational system (OS).

$ pip3 install virtualenv

Next step is create your local enverioment with command bellow:

$ virtualenv -p python3.6 venv

Activating a virtualenv

After creating a virtualenv, we need to activate it so that we can install the necessary project packages. For this, we use the following command:

  • source venv/bin/activate (Linux ou macOS)
  • venv/Scripts/Activate (Windows)

Installing packages

With virtualenv enabled, we can install the necessary packages using the PIP itself:

$ pip install -r requirements.txt

Settings Nanobrok-server

Database settings

By default nanobrok use the dababase of postgresql to save all data, but you can set your database manager in settings.toml, checkout how to config connection URI with flask.

Using sqlite

The sqlite is a great way to use for test nanabrok in your localhost, it more easy to setup:

1 - Open the settings.toml file and find the SQLALCHEMY_DATABASE_URI in section [localhost]. 2 - Now, you should be configure or set your .db file like this 'sqlite:///development.db' the value of SQLALCHEMY_DATABASE_URI is a string with path of file sqlite.

Settings file .env

The evenrioment is a great way to settings your server with more secure, in this file you should be add somes information about your env, and somes flag of flask, you need to create this file on current root folder of the project. see the example:

FLASK_ENV=development
FLASK_DEBUG=1
FLASK_APP=nanobrok.app:create_app()

look, the variable FLASK_ENV is a name your section in settings.toml if you want to run with localhost settings your should be change this option on file .env. after that you can run the command: flask run for mount your server or use the makefile make start.

Initial commands about

After create your .env file, now you can to settings,build and populate your database. the nanabrok-server have somes command line, checkout:

# type flask in terminal to show this
  add-user          Adds a new user to the database
  create-db         Creates database
  db                Perform database migrations.
  drop-db           Cleans database
  populate-db       Populate db with sample data
  populate-db-dev   Populate db with sample data
  populate-db-prod  Populate db with data for production
  routes            Show the routes for the app.
  run               Run a development server.
  shell             Runs a shell in the app context.

Commands: This command bellow is used for create the tables into database file or manager.

flask create-db

This command bellow is used for populate the default user admin, after run this command it recommanded change the default username and password in file nanobrok/ext/commands.py.

$ flask populate-db

This command bellow is used for delete all tables into database.

$ flask drop-db

This command bellow s used for start the webserver (nanobrok-server) with flask application.

$ flask run

How to use flask commands

frist of all, the commands populate-db and create-db is made for run after on setup your remote server, follow the steps for create the all tables in database and create the frist username and password of nanobrok-server:

$ flask create-db
$ flask populate-db

after that, the only thing you should do is run the service of nanobrok applicaiton, look the param --host is used when your is running in localhost:

$ flask run --host 0.0.0.0 --port 5000

now, open the browser type http://localhost:50000 if your running in localhost.

Heroku

Clone this wiki locally