NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

from django.shortcuts import render,redirect
from django.http import HttpResponse
from django.shortcuts import render, redirect
from django.contrib import messages
from django.contrib.auth import authenticate, login, logout
from django.contrib.auth.models import User
from django.contrib.auth.models import User
from django.contrib import messages
from django.shortcuts import render, redirect
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework import status
from .serializers import CardInformationSerializer
import stripe


# Create your views here.
def navbar(request):
return render(request,'navbar.html')
def about(request):
return render (request,'about.html')
def home(request):
return render (request, 'home.html' )





# def home2(request):
# return render(request, 'index.html')

from django.contrib import messages
from django.shortcuts import render, redirect
from django.contrib.auth.models import User
import re # Regular expressions for email validation

def signup(request):
if request.method == "POST":
try:
username = request.POST['username']
fname = request.POST['fname']
lname = request.POST['lname']
email = request.POST['email']
pass1 = request.POST['pass1']
pass2 = request.POST['pass2']

error_messages = []


if len(username) < 3:
error_messages.append("Username must be at least 3 characters long.")


if len(fname) < 1:
error_messages.append("First name is required.")


if len(lname) < 1:
error_messages.append("Last name is required.")


email_pattern = r'^[w.-]+@[w.-]+.w+$'
if not re.match(email_pattern, email):
error_messages.append("Please enter a valid email address.")


if len(pass1) < 6:
error_messages.append("Password must be at least 6 characters long.")
if pass1 != pass2:
error_messages.append("Passwords do not match.")


if error_messages:
for message in error_messages:
messages.error(request, message)
return render(request, 'signup.html')

# If no errors, create the user
myuser = User.objects.create_user(username=username, email=email, password=pass1)
myuser.first_name = fname
myuser.last_name = lname
myuser.save()

messages.success(request, "Your account has been created successfully. You can now log in.")
return redirect('signin')

except Exception as e:
messages.error(request, f"An error occurred: {str(e)}")
return render(request, 'signup.html')

return render(request, 'signup.html')



def signin(request):
if request.method == "POST":
try:
username = request.POST['username']
pass1 = request.POST['pass1']

user = authenticate(username=username, password=pass1)
if user is not None:
login(request, user)
fname = user.first_name
return render(request, 'index.html', {'fname': fname})
else:
messages.error(request, "Bad credentials!")
return redirect('home')

except Exception as e:
messages.error(request, f"An error occurred: {str(e)}")
return redirect('home')

return render(request, 'signin.html')

def signout(request):
logout(request)
messages.success(request, "Logged out successfully!")
return redirect('home')


def check(request):
return render (request, 'checkbox.html')


def test(request):
return render (request, "test.html")


def consultation(request):
return render (request, 'consultation.html')


def Emergency (request):

return render (request, 'Emergency.html')


def Surgery (request):
return render (request, 'Surgery.html')


def Radiology(request):
return render (request, 'Radiology.html')


def other_service(request):
return render (request, 'othe_service.html')


def Ai_chat(request):
pass

def logout_view(request):
logout(request) # Log out the user
return redirect('signin')

# Payment integraction



class PaymentAPI(APIView):
serializer_class = CardInformationSerializer

def post(self, request):
serializer = self.serializer_class(data=request.data)
response = {}

if serializer.is_valid():
data_dict = serializer.data

stripe.api_key = 'sk_test_51QjHnbHwnv9ZDZEAY9GQOiZv7C3OcudNnuIKcXJBvRQTD89yvz4MFexGtD7216FwcFiPhLvoBsOpnAATJmDfct8M00zzIAndye'
response = self.stripe_card_payment(data_dict=data_dict)
else:
response = {
'errors': serializer.errors,
'status': status.HTTP_400_BAD_REQUEST
}

return Response(response)

def stripe_card_payment(self, data_dict):
try:
card_details = {
"type": "card",
"card": {
"number": data_dict['card_number'],
"exp_month": data_dict['expiry_month'],
"exp_year": data_dict['expiry_year'],
"cvc": data_dict['cvc'],
},
}

# You can also get the amount from the database by creating a model
payment_intent = stripe.PaymentIntent.create(
amount=10000,
currency='inr',
)

payment_intent_modified = stripe.PaymentIntent.modify(
payment_intent['id'],
payment_method=card_details['id'],
)

try:
payment_confirm = stripe.PaymentIntent.confirm(
payment_intent['id']
)
payment_intent_modified = stripe.PaymentIntent.retrieve(payment_intent['id'])
except:
payment_intent_modified = stripe.PaymentIntent.retrieve(payment_intent['id'])
payment_confirm = {
"stripe_payment_error": "Failed",
"code": payment_intent_modified['last_payment_error']['code'],
"message": payment_intent_modified['last_payment_error']['message'],
'status': "Failed"
}

if payment_intent_modified and payment_intent_modified['status'] == 'succeeded':
response = {
'message': "Card Payment Success",
'status': status.HTTP_200_OK,
"card_details": card_details,
"payment_intent": payment_intent_modified,
"payment_confirm": payment_confirm
}
else:
response = {
'message': "Card Payment Failed",
'status': status.HTTP_400_BAD_REQUEST,
"card_details": card_details,
"payment_intent": payment_intent_modified,
"payment_confirm": payment_confirm
}
except:
response = {
'error': "Your card number is incorrect",
'status': status.HTTP_400_BAD_REQUEST,
"payment_intent": {"id": "Null"},
"payment_confirm": {'status': "Failed"}
}

return response




#chat =



def chat(request):
if request.method=="POST":
input_data=request.POST['chat_input']
print("input",input_data)
repo_id ="impira/layoutlm-document-qa"
print("rep_id","****************")
repo_id=repo_id,
HUGGINGFACEHUB_API_TOKEN='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'

print("lllllllllllllllllllllllllllllll")
repo_id ="impira/layoutlm-document-qa"
repo_id ="mistralai/Mistral-7B-v0.1"
llm = HuggingFaceEndpoint(
repo_id=repo_id,
max_length= 128,
temperature=0.7,
token="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"

)

print("uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu")

# out_put=llm.predict(input_data)
# export HUGGINGFACE_TOKEN=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
out_put = llm.predict(input_data)
print(out_put,"ppppppppppppppppppp")
# return JsonResponse({'response': out_put})
return render (request,"home.html",{'data':out_put})
return render(request,"home.html")

     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.