Moderator
@srish What's the programming language you're using?
Votes
0
Replies
24
Participants
Unknown
Messages
25
Moderator
@srish What's the programming language you're using?
Moderator
seems to be python
Rank 1: Thread
Yes python
Rank 1: Thread
See is there any error?
Moderator
You should do this:
result = users.create(ID.unique(), email=email, password=password, name=name)```Moderator
import ID from appwrite SDK
Moderator
Remove this code:
# Generate a unique user_id using the email address and a unique identifieruserid = re.sub(r'[^a-zA-Z0-9.-]', '', email) # Remove any special characters from the emailuserid += '' + str(uuid.uuid4())user_id = user_id[:36]Rank 1: Thread
Here is the updated code
Rank 1: Thread
But still showing the same error
Rank 4: Virtual Machine
In the first image, remove your validation of user id. You are not supposed to validate user id yourself, appwrite does it on the backend and the returned error may be handled on the frontend.
FYI, ID.unique() returns the string unique() and the backend generates an unique id internally
Rank 1: Thread
R u talking about user_id=ID.unique()?
Rank 1: Thread
This line👆
Admin
Btw, it's best to use 3 back ticks with multi-line code. See https://www.markdownguide.org/extended-syntax/#syntax-highlighting
Moderator
Your code should be someting like this:
@app.route('/signup', methods=['GET', 'POST'])def signup(): error_message = None if request.method == 'POST': # Retrieve form data email = request.form['email'] password = request.form['password'] name = request.form['name'] if 'name' in request.form else ''
try: result = users.create(ID.unique(), email=email, password=password, name=name) response = account.create_session(email, password) session_data = response.json() # Store the session data in the user's session session['userId'] = session_data['userId'] session['email'] = email session['token'] = session_data['$id'] # Redirect to the login page after successful signup return redirect(url_for('login')) except Exception as e: error_message = str(e)
# Render the signup template return render_template('signup.html', error_message=error_message)Rank 1: Thread
Okie let me try this one
Rank 1: Thread
Rank 1: Thread
Now how to solve this?
Admin
You never called client.setEndpoint()
Admin
what is account.create_session(email, password)?
did chatGPT generate this?? 😅
Rank 1: Thread
How to call client.setEndpoint()
Admin
this might be helpful: https://appwrite.io/docs/getting-started-for-server
We have lots of docs so make sure to go through them thoroughly
Admin
Getting started with the python SDK
Rank 1: Thread
I have set endpoint
Rank 1: Thread
But still it is showing error
Admin
please share the exact error and your updated code