-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
37 lines (27 loc) · 1016 Bytes
/
app.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
import os
from flask import Flask
from flask_cors import CORS
from flask_restful import Api
from flask_sqlalchemy import SQLAlchemy
from dotenv import load_dotenv
from datetime import datetime
from resources.index_route import IndexRoute
from resources.user_route import UserRoute
from resources.middlewares.auth import Auth
load_dotenv()
app = Flask(__name__)
app.wsgi_app = Auth(app.wsgi_app)
app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv("DATABASE_URL")
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)
CORS(app)
api = Api(app, "/api")
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(50))
email = db.Column(db.String(100), unique=True)
date_joined = db.Column(db.Date, default=datetime.utcnow)
def __repr__(self):
return f'<User>: {self.email}>'
api.add_resource( IndexRoute, "/", methods=["GET"] )
api.add_resource( UserRoute, '/<int:user_id>/', methods=["GET"] )