added single config.ini to change variables

This commit is contained in:
Navan Chauhan 2020-09-08 20:03:41 +05:30
parent b8ada840cf
commit 37076cab79
4 changed files with 61 additions and 15 deletions

View File

@ -1,9 +1,26 @@
from flask import Flask
# Config Values
import configparser
config = configparser.ConfigParser()
config.read('config.ini')
DB_HOST = config['DATABASE']['HOST']
DB_PORT = config['DATABASE']['PORT']
DB_USER = config['DATABASE']['USER']
DB_PASSWORD = config['DATABASE']['PASSWORD']
DB_NAME = config['DATABASE']['NAME']
UPLOAD_FOLDER = config['FILES']['UPLOAD_FOLDER']
"""
# Hardcoded Values
# location where file uploads will be stored
UPLOAD_FOLDER = './app/static/uploads'
DB_HOST = 'navanspi.duckdns.org' #'navanspi.duckdns.org'
DB_PORT = 3306
DB_USER = 'curieweb'
DB_PASSWORD = 'curie-web-russian-54'
DB_NAME = 'curie'
"""
import subprocess
import hashlib
@ -16,10 +33,7 @@ try:
except:
None
DB_PORT = 3306
DB_USER = 'curieweb'
DB_PASSWORD = 'curie-web-russian-54'
DB_NAME = 'curie'
# needed for session security, the flash() method in this case stores the message
# in a session
SECRET_KEY = 'Sup3r$3cretkey'

View File

@ -8,7 +8,16 @@ from collections import namedtuple
import mysql.connector as con
mycon = con.connect(host='192.168.1.6',user="curieweb",password="curie-web-russian-54",port=3306,database="curie")
import configparser
config = configparser.ConfigParser()
config.read('config.ini')
try:
config['DATABASE']
except KeyError:
config.read("../config.ini")
mycon = con.connect(host=config['DATABASE']['HOST'],user=config['DATABASE']['USER'],password=config['DATABASE']['PASSWORD'],port=config['DATABASE']['PORT'],database=config['DATABASE']['NAME'])
mycursor = mycon.cursor()
sql_select_Query = "SELECT id,email,pdb,ligand_smile,ligand_name,description,date FROM curieweb WHERE pdb IS NOT NULL AND done=0 LIMIT 1"

View File

@ -1,6 +1,15 @@
import mysql.connector as con
mycon = con.connect(host='192.168.1.6',user="curieweb",password="curie-web-russian-54",port=3306,database="curie")
import configparser
config = configparser.ConfigParser()
config.read('config.ini')
try:
config['DATABASE']
except KeyError:
config.read("../config.ini")
mycon = con.connect(host=config['DATABASE']['HOST'],user=config['DATABASE']['USER'],password=config['DATABASE']['PASSWORD'],port=config['DATABASE']['PORT'],database=config['DATABASE']['NAME'])
mycursor = mycon.cursor()
sql_select_Query = "select * from curieweb where done=0 LIMIT 1"

14
config.ini Normal file
View File

@ -0,0 +1,14 @@
[DATABASE]
HOST = navanspi.duckdns.org
PORT = 3306
USER = curieweb
PASSWORD = curie-web-russian-54
NAME = curie
[LOGS]
ERRORS = logs/errors.log
INFO = data/info.log
[FILES]
UPLOAD_FOLDER = ./app/static/uploads
TEMPLATES_FOLDER = templates