Commit 0b0caf3f authored by kranthi.kumar's avatar kranthi.kumar

basic

parent a33458bd
import logging
from flask import Flask
from scripts.service.login_service import blueprint_inserter
app = Flask(__name__)
app.register_blueprint(blueprint_inserter)
try:
if __name__ == '__main__':
app.run(port=8200)
except Exception as e:
logging.exception("Exception occurred", exc_info=True)
print(e)
from scripts.handler.utility import Mongo_utility
utility_object = Mongo_utility()
class Mongobd:
@staticmethod
def insert(data):
register_details = utility_object.connection()
utility_object.insert(register_details, data)
@staticmethod
def find_query(username, password):
register_details = utility_object.connection()
myCursor = utility_object.finding(register_details, {"User Id": username})
# pawd= utility_object.finding(register_details, {"Password": password})
flag = 0
for key, value in myCursor.next().items():
if (key == "Password" and value == password):
flag = 1
return flag
import logging
from pymongo import MongoClient
class Mongo_utility:
@staticmethod
def connection():
try:
client = MongoClient('143.110.191.155', 37217)
database = client.kranthi
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:
# we can use insert_many for insertion all records at a time.
register_details.insert(data)
except Exception:
logging.exception("Exception occurred", exc_info=True)
@staticmethod
def finding(register_details, query):
try:
details = register_details.find(query)
return details
except Exception:
logging.exception("Exception occurred", exc_info=True)
raise Exception("Problem in Searching")
import json
import logging
from flask import Blueprint
from flask import render_template, request
from scripts.handler.login_handler import Mongobd
blueprint_inserter = Blueprint('example_blueprint', __name__)
mongodb_object=Mongobd()
try:
@blueprint_inserter.route('/login')
def message():
return render_template('login.html')
@blueprint_inserter.route('/registration')
def message1():
return render_template('registration.html')
@blueprint_inserter.route('/registration_success')
def message2():
return render_template('registration_success.html')
@blueprint_inserter.route('/registration_data',methods = ['POST'])
def input_values():
data={"Name":request.form["name"],"Phone number":
request.form["number"],"Mail id":
request.form["mail"],"User Id":
request.form["user_id"],"Password":
request.form["password"]}
mongodb_object.insert(data)
return render_template('registration_success.html')
@blueprint_inserter.route('/login_data', methods=['POST'])
def required_values():
result=mongodb_object.find_query(request.form["username"],request.form["pwd"])
if(result==1):
return render_template('login_success.html')
else:
return render_template('login_fail.html')
except Exception as e:
logging.exception("Exception occurred in connection", exc_info=True)
print(e)
<!Doctype html>
<html>
<body style="background-color:powderblue;">
<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">Login Fail . Please try again</h1>
<a href="login">click here to Login :<input type="button" onclick="login" value="login"></a>
</body>
</html>
\ No newline at end of file
<!Doctype html>
<html>
<body style="background-color:powderblue;">
<h1 align="center">login Successfull</h1>
</body>
</html>
\ No newline at end of file
<!Doctype html>
<html>
<body style="background-color:powderblue;">
<h1 align="center">Welcome To Knoeledge 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><a href="registration_success"><input type="submit" onclick="login" value="Register"></a></a></td>td>
</tr>
</table>
</form>
</body>
</html>
\ No newline at end of file
<!Doctype html>
<html>
<body style="background-color:powderblue;">
<h1 align="center">RegiStration Successfull</h1>
<a href="login">click here to Login :<input type="button" onclick="login" value="login"></a>
</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