-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogeo.py
53 lines (40 loc) · 1.34 KB
/
logeo.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
import os
import csv
from flask import Flask, render_template, request
from flask_sqlalchemy import SQLAlchemy
from models import Usuario
from google import getGoogleData
app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = "postgres://rrcgpldedfwzsy:a327a7d195c293981f53baa91a8af5045c10ce642fd44b61ed87f2c77723e013@ec2-52-44-55-63.compute-1.amazonaws.com:5432/dc1scm7s3mgdqv"
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
db = SQLAlchemy()
db.init_app(app)
def no_authent():
user = Usuario(usuario="Guest", password="")
db.session.add(user)
db.session.commit()
return user.id
def get_session(user_id):
return Usuario.query.get(user_id)
def get_sessionUser(username):
return Usuario.query.filter_by(usuario=username).first()
def already_exists(username):
usuario = Usuario.query.filter_by(usuario=username).first()
if usuario:
return True
return False
def create_user(username, password):
if already_exists(username):
return None
user = Usuario(usuario=username, password=password)
db.session.add(user)
db.session.commit()
return user
def verify_user(username, password):
usuario = Usuario.query.filter_by(usuario=username).first()
if usuario is None:
return False
if usuario.password != password:
return False
else:
return True