-
Notifications
You must be signed in to change notification settings - Fork 24
/
test.py
52 lines (38 loc) · 1.19 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from flask import Flask,request,jsonify
from datetime import datetime
import os
from flask_sqlalchemy import SQLAlchemy
from flask_bcrypt import Bcrypt
from flask_login import LoginManager
from pymongo import MongoClient
app = Flask(__name__)
app.config['SECRET_KEY'] = 'e23739c67eade607c64f90c3ebb479ca'
'''app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///site.db'
db = SQLAlchemy(app)'''
client= MongoClient("mongodb://localhost:27017")
db = client.resume
users = db["users"]
bcrypt = Bcrypt(app)
@app.route("/register",methods=['POST'])
def register():
data = request.get_json()
username = data["username"]
password = data["password"]
email = data["email"]
hashed = bcrypt.generate_password_hash(password).decode('utf-8')
'''new_user = user(username=form.username.data,email=form.email.data,password=hashed)
db.session.add(new_user)
db.session.commit()'''
users.insert({
"username": username,
"email": email,
"password": hashed
})
ret={
"status": 200,
"msg": "user made"
}
#flash(f'Account Created for {fousername}!','success')
return jsonify(ret)
if __name__ == '__main__':
app.run(debug=True)