Commit 6594df92 authored by kranthi.kumar's avatar kranthi.kumar

basic

parent 3b19c867
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
import logging
from flask import Flask,session
from scripts.service.login_service import blueprint_object
app = Flask(__name__)
app.secret_key = 'super secret key'
app.register_blueprint(blueprint_object)
try:
if __name__ == '__main__':
app.run(port=8300)
except Exception as e:
logging.exception("Exception occurred", exc_info=True)
print(e)
import bcrypt
from scripts.handler.utility import Mongo_utility
# creating object for class in Utility
utility_object = Mongo_utility()
class Mongobd:
# method for inserting data into database
@staticmethod
def insert(data, username):
# connecting to database
register_details = utility_object.connection()
# find the data based on user_name in database
require_data = utility_object.finding(register_details, {"User Id": username})
flag = 0
# checking if user exists or not
if len(list(require_data)) == 0:
flag = 1
# if user not exists then inserting data to database
if flag == 1:
utility_object.insert(register_details, data)
return flag
# method for validating user data with database
@staticmethod
def find_query(username, password):
# connecting to database
register_details = utility_object.connection()
cursor_list = list(utility_object.finding(register_details, {"User Id": username}))
flag = 0
# checking if user exists or not
if len(cursor_list) != 0:
# if user exists then finding the password using username as query
cursor = utility_object.finding(register_details, {"User Id": username})
for key, value in cursor.next().items():
# validating user password with database password
# we use bcrypt.checkpw to compare hashed password
if key == "Password" and bcrypt.checkpw(password.encode('utf8'), value):
flag = 1
break
else:
flag = 2
return flag
import logging
from pymongo import MongoClient
class Mongo_utility:
# method for connecting with database
@staticmethod
def connection():
try:
# database details
client = MongoClient('143.110.191.155', 37217)
# kranthi -> database name
database = client.kranthi
# register_details -> collection name
register_details = database.register_details
return register_details
except Exception:
logging.exception("Exception occurred in connection", exc_info=True)
@staticmethod
def insert(register_details, data):
try:
# inserting data into database.
register_details.insert(data)
except Exception:
logging.exception("Exception occurred", exc_info=True)
@staticmethod
def finding(register_details, query):
try:
# finding data based on query
details = register_details.find(query)
return details
except Exception:
logging.exception("Exception occurred", exc_info=True)
import logging
import bcrypt
from flask import Blueprint
from flask import render_template, request, flash
from scripts.handler.login_handler import Mongobd
blueprint_object = Blueprint('example_blueprint', __name__)
mongodb_object = Mongobd()
try:
# To open login page
@blueprint_object.route('/')
def login():
return render_template('login.html')
# To open registration page
@blueprint_object.route('/registration')
def registration():
return render_template('registration.html')
# To get registration details
@blueprint_object.route('/registration_data', methods=['POST'])
def input_values():
# collecting user details from registration.html
data = {"Name": request.form["name"], "Phone number": request.form["number"], "Mail id": request.form["mail"],
"User Id": request.form["user_id"],
"Password": bcrypt.hashpw((request.form["password"]).encode('utf8'), bcrypt.gensalt())}
if request.form["password"] == request.form["r_password"]:
# sending data to the database.
result = mongodb_object.insert(data, request.form["user_id"])
if result == 1:
# works when user is successfully register
flash("you have successfully register. you can login here :")
# It redirect to login page after successfully register
return render_template('login.html')
else:
# If user enter the same user Id already exists
error = "User id already exists"
# It redirect to registration page along with error
return render_template('registration.html', error=error)
else:
# If user enter the same user Id already exists
error = "password and Retype password must be same"
# It redirect to registration page along with error
return render_template('registration.html', error=error)
# To get login details
@blueprint_object.route('/login_data', methods=['POST'])
def required_values():
# sending the username,password for checking
result = mongodb_object.find_query(request.form["username"], request.form["pwd"])
if result == 1:
# work when login details are correct and redirect to website page
return render_template('login_success.html')
elif result == 2:
# work when user is new to website
error = "First Register here"
# It redirect to registration page along with error
return render_template('registration.html', error=error)
else:
# Works when user entered new password
error = "please enter correct password"
# It redirect to login page along with error
return render_template('login.html', error=error)
except Exception as e:
logging.exception("Exception occurred in connection", exc_info=True)
print(e)
<!Doctype html>
<html>
<body style="background-color:powderblue;">
{% with messages = get_flashed_messages() %}
{% if messages %}
{% for message in messages %}
<p>{{ message }}</p>
{% endfor %}
{% endif %}
{% endwith %}
{% if error %}
<p><strong>Error</strong>: {{error}}</p>
{% endif %}
<h1 align="center">Welcome To Knowledge Lens</h1>
<h2 align="center">Login Page</h2>
<form name="f1" action="login_data" method="post">
<table align="center" border="0" bgcolor="green" cellspacing="10" cellpadding="5">
<td>Username:</td>
<td><input type="text" size=25 name="username" required></td>
</tr></tr></tr>
<td>Password:</td>
<td><input type="Password" size=25 name="pwd" required></td>
</tr>
<tr>
<td><input type="submit" name="b1" value="login"></td>
<td>
<a href="registration">
<input type="button" onclick="registration" value="Registration"> </a>
</td>
</table>
</form>
</body>
</html>
\ No newline at end of file
<!Doctype html>
<html>
<body style="background-color:powderblue;">
<h1 align="center">welcome to Knowledge lens</h1>
<h3>About us </h3>
<h4>
Knowledge Lens is a US and India based product and services technology company that builds innovative solutions on
niche technology areas such as Big Data Analytics, Data Science, Artificial Intelligence, IoT, Blockchain, AR/VR and
Cloud.
We have successfully transformed companies into Smart Enterprises by implementing Next Generation Enterprise Data
Lakes, AI Powered Intelligent Apps and Industry 4.0 solutions both on premise and cloud.
Our mission is to discover intelligent insights from enterprise data and deliver business value to customers. We
have a technically strong team of 350+ experts working to add differentiated value to our customers. What truly sets
us apart is the use of a microservice-based architecture, to expand solution capabilities without disrupting
critical business activities. This enables us to provide user-focused, domain-specific software applications built
on cutting edge, adaptive technologies.</h4>
<h3>Your Products:</h3>
<h3>&nbsp; &nbsp; &nbsp; &nbsp; GLens</h3>
<h4>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GLens is Real-Time Data Acquisition, Monitoring and
Analytics suite of Products for Industrial Emissions, Effluent Discharges and Ambient Air Monitoring. GLens DAS
Software, GLens Server Platform, GLens Environ Data Logger provides a comprehensive solution for all Industry
Environmental needs.</h4>
<h3>&nbsp; &nbsp; &nbsp; &nbsp; MLens</h3>
<h4>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MLens is an accelerator toolkit from Knowledge Lens which
enables Workload Migration, Cloud Data Management & Automated Disaster Recovery for Enterprise. We provide migration
utilities to migrate data, metadata & transform computational workloads in Hadoop environment to Databricks Unified
Analytics.</h4>
<h3> &nbsp; &nbsp; &nbsp; &nbsp;ILens</h3>
<h4> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;iLens is our premier Industrial IoT solution, addressing
Industry 4.0 demands with capabilities including Interface Connectivity, Edge Analytics and Predictive Analytics. We
are currently powering automation, manufacturing, energy and utility companies across the world.</h4>
</body>
</html>
\ No newline at end of file
<!Doctype html>
<html>
<body style="background-color:powderblue;">
{% with messages = get_flashed_messages() %}
{% if messages %}
<ul>
{% for message in messages %}
<li>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
{% if error %}
<p><strong>Error</strong>: {{error}}</p>
{% endif %}
<h1 align="center">Welcome To Knowledge Lens</h1>
<h2 align="center">REGISTRATION PAGE</h2>
<form name="f1" action="registration_data" method="post">
<table align="center" border="0" bgcolor="green" cellspacing="10" cellpadding="5">
<tr>
<td>Name:</td>
<td><input type="text" name="name" size="15" required></td>
</tr>
<tr>
<td>Phone No:</td>
<td><input type="text" name="number" size="15" required></td>
</tr>
<tr>
<td>Mail id:</td>
<td><input type="email" name="mail" size="15" required></td>
</tr>
<tr>
<td>User id:</td>
<td><input type="text" name="user_id" size="15" required></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="password" size="15" required></td>
</tr>
<tr>
<td>Retype Password:</td>
<td><input type="password" name="r_password" size="15"></td>
</tr>
<tr>
<td><a href="registration_success"><input type="submit" onclick="login" value="Register"></a></td>
</tr>
</table>
</form>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment