Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update app.py #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 64 additions & 7 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,64 @@
def app(environ, start_response):
data = b"Hello, World!\n"
start_response("200 OK", [
("Content-Type", "text/plain"),
("Content-Length", str(len(data)))
])
return iter([data])
from flask import Flask
from flask import request
from firebase_admin import credentials
from firebase_admin import auth
from firebase_admin import firestore
import firebase_admin
from pathlib import Path

app = Flask(__name__)

@app.route('/')
def hello_world():
return 'Hello, World!'


THIS_FOLDER = Path(__file__).parent.resolve()
my_file = THIS_FOLDER/"/service.json"
app = Flask(__name__)


cred =credentials.Certificate('service.json')
firebase_admin.initialize_app(cred)

db = firestore.client()

@app.route("/custom",methods=["POST"])
def customToken():
m_no=request.form['M_No']
password=request.form['Password']
doc_ref = db.collection("phone_pass").document(m_no)
doc = doc_ref.get()
if doc.exists:
passs = doc_ref.get(field_paths={'password'}).to_dict().get('password')
if(passs==password):
user_id = doc_ref.get(field_paths={'uid'}).to_dict().get('uid')
custom_token = auth.create_custom_token(user_id)
return custom_token
else:
return "true"
else:
return "false"


@app.route("/forget",methods=["POST"])
def forgot():
m_no=request.form['M_No']
doc_ref = db.collection("phone_pass").document(m_no)
doc = doc_ref.get()
if doc.exists:
user_id = doc_ref.get(field_paths={'uid'}).to_dict().get('uid')
custom_token = auth.create_custom_token(user_id)
return custom_token
else:
return "false"

@app.route("/register",methods=["POST"])
def register():
m_no=request.form['M_No']
doc_ref = db.collection("phone_pass").document(m_no)
doc = doc_ref.get()
if doc.exists:
return "true"
else:
return "false"