added check for WiFi @ Home

This commit is contained in:
Navan Chauhan 2020-08-24 16:14:23 +05:30
parent ae27a5c999
commit 46192b0a03
3 changed files with 15 additions and 2 deletions

View File

@ -4,6 +4,18 @@ from flask import Flask
# location where file uploads will be stored # location where file uploads will be stored
UPLOAD_FOLDER = './app/static/uploads' UPLOAD_FOLDER = './app/static/uploads'
DB_HOST = 'navanspi.duckdns.org' #'navanspi.duckdns.org' DB_HOST = 'navanspi.duckdns.org' #'navanspi.duckdns.org'
import subprocess
import hashlib
ssid = b'j\xa0\x1b\xd6p\xe9\xa4\\b\x12\xedD\xaeX\x8a\xf8'
try:
output = subprocess.check_output(['sudo', 'iwgetid'])
if hashlib.md5(bytes(output.decode().split('"')[1],encoding="utf-8")).digest() == ssid:
DB_HOST = '192.168.1.6'
except:
None
DB_PORT = 3306 DB_PORT = 3306
DB_USER = 'curieweb' DB_USER = 'curieweb'
DB_PASSWORD = 'curie-web-russian-54' DB_PASSWORD = 'curie-web-russian-54'

View File

@ -1,6 +1,7 @@
import mysql.connector as con import mysql.connector as con
from app import app
mycon = con.connect(host="192.168.1.6",user="curieweb",password="curie-web-russian-54",port=3306,database="curie") mycon = con.connect(host=app.config['DB_HOST'],user="curieweb",password="curie-web-russian-54",port=3306,database="curie")
mycursor = mycon.cursor() mycursor = mycon.cursor()
sql_select_Query = "select * from curieweb where done=0 LIMIT 1" sql_select_Query = "select * from curieweb where done=0 LIMIT 1"

View File

@ -133,7 +133,7 @@ def wtform():
flash_errors(myform) flash_errors(myform)
return render_template('wtform.html', form=myform) return render_template('wtform.html', form=myform)
tfWorking = 0 tfWorking = -1
if tfWorking == -1: if tfWorking == -1:
try: try: