-
Notifications
You must be signed in to change notification settings - Fork 39
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
- docker
The nanobrok-server can be to install easily using the virtualenv, you should be install the virtualenv your python version.
Installing a virtualenv is done using pip, Python's package manager. follow a google tutorial how to install pip your Operational system (OS).
$ pip install virtualenv
Next step is create your local enverioment with command bellow:
$ virtualenv -p python3.6 venv
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)
With virtualenv enabled, we can install the necessary packages using the PIP itself:
$ pip install -r requirements.txt
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.
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.
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
.
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
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
© Copyright 2021, Nanobrok - P0cL4bs Team