From c995a47f463a1623c51f45f1a1157b9687858ae0 Mon Sep 17 00:00:00 2001 From: Amlan Date: Wed, 24 Feb 2021 18:51:54 +0530 Subject: [PATCH] Created .env file and updated Readme --- README.md | 27 +++++++++++++++------------ tensormap-server/.envsample | 2 ++ tensormap-server/.gitignore | 3 +++ tensormap-server/app/__init__.py | 9 +++++++-- 4 files changed, 27 insertions(+), 14 deletions(-) create mode 100644 tensormap-server/.envsample diff --git a/README.md b/README.md index 9bbb51d1..8e88e774 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,28 @@ -[![Build Status](https://travis-ci.com/scorelab/TensorMap.svg?branch=master)](https://travis-ci.com/scorelab/TensorMap) [![Join the chat at https://gitter.im/scorelab/TensorMap](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/scorelab/TensorMap) +[![Build Status](https://travis-ci.com/scorelab/TensorMap.svg?branch=master)](https://travis-ci.com/scorelab/TensorMap) [![Join the chat at https://gitter.im/scorelab/TensorMap](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/scorelab/TensorMap) [![HitCount](http://hits.dwyl.com/scorelab/TensorMap.svg)](http://hits.dwyl.com/scorelab/TensorMap) - - # TensorMap TensorMap is a web application that will allow the users to create machine learning algorithms visually. TensorMap supports reverse engineering of the visual layout to a Tensorflow implementation in preferred languages. The goal of the project is to let the beginners play with machine learning algorithms in Tensorflow without less background knowledge about the library. For more details about the project, read our [project wiki.](https://github.com/scorelab/TensorMap/wiki) ## Getting Started + Follow these steps to set up TensorMap on your local machine. First clone this repo by running + ```bash git clone https://github.com/scorelab/TensorMap.git -``````````````````````````` +``` ### Setting up Frontend #### Prerequisites -* Node.js -* Yarn -* Npm + +- Node.js +- Yarn +- Npm ```bash cd TensorMap @@ -54,13 +55,15 @@ mysql -u -p CREATE DATABASE tensormap; ``` -Then in the '__init__' file that is inside the 'app' folder, replace the database connection string with your username and password +Create a .env file based on the format provided in .envsample file, add your database connection string and secret ```bash -app.config['SQLALCHEMY_DATABASE_URI'] = "mysql://:@localhost/tensormap" +DATABASE_URI=mysql://:@localhost:/tensormap +SECRET_KEY=secret ``` Next, restore the sql dump + ```bash mysql -u {user} -p -Dtensormap < {path-to-dump-file}/dump.sql ``` @@ -73,9 +76,9 @@ python run.py ## Built With -* [Reactjs](https://reactjs.org/docs/getting-started.html) : Frontend -* [Flask](http://flask.pocoo.org/) : Backend -* [TensorFlow - Keras](https://www.tensorflow.org/) : Model implemetation +- [Reactjs](https://reactjs.org/docs/getting-started.html) : Frontend +- [Flask](http://flask.pocoo.org/) : Backend +- [TensorFlow - Keras](https://www.tensorflow.org/) : Model implemetation ## Contributing diff --git a/tensormap-server/.envsample b/tensormap-server/.envsample new file mode 100644 index 00000000..ffc47cc2 --- /dev/null +++ b/tensormap-server/.envsample @@ -0,0 +1,2 @@ +DATABASE_URI=mysql://:@localhost:/tensormap +SECRET_KEY=secret \ No newline at end of file diff --git a/tensormap-server/.gitignore b/tensormap-server/.gitignore index b5b4c6d8..39c22650 100644 --- a/tensormap-server/.gitignore +++ b/tensormap-server/.gitignore @@ -289,4 +289,7 @@ $RECYCLE.BIN/ # Windows shortcuts *.lnk +# Misc +/flask_session + # End of https://www.gitignore.io/api/linux,macos,python,windows,pycharm,visualstudiocode diff --git a/tensormap-server/app/__init__.py b/tensormap-server/app/__init__.py index 7b627d5d..c62ce5ce 100644 --- a/tensormap-server/app/__init__.py +++ b/tensormap-server/app/__init__.py @@ -3,6 +3,7 @@ from flask_sqlalchemy import SQLAlchemy from flask_cors import CORS, cross_origin from flask_session import Session +from dotenv import load_dotenv import os socketio = SocketIO() @@ -12,12 +13,16 @@ def create_app(debug=False): app = Flask(__name__) + + # Load environment variables + load_dotenv() + app.debug = debug app.config['SESSION_TYPE'] = 'filesystem' - app.config['SECRET_KEY'] = 'secret' + app.config['SECRET_KEY'] = os.getenv("SECRET_KEY") app.config['USE_PERMANENT_SESSION'] = True # app.config['SECRET_KEY'] = os.urandom(25) - app.config['SQLALCHEMY_DATABASE_URI'] = "mysql://root:pass@localhost/tensormap" + app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv("DATABASE_URI") app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False from .resources import main