-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.py
More file actions
35 lines (28 loc) · 912 Bytes
/
api.py
File metadata and controls
35 lines (28 loc) · 912 Bytes
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
from flask import Flask, request, jsonify, make_response
from services.iotAPI import iotAPI
from services.user_auth import loginService
from database_controller import db
from utils.logger import Logger
from services.user_auth import SECRET_KEY as SK
import os
from werkzeug.security import generate_password_hash, check_password_hash
from functools import wraps
import uuid, jwt, datetime
# global configs
app = Flask(__name__)
app.config['SECRET_KEY'] = SK
# database configuration
basedir = os.path.abspath(os.path.dirname(__file__))
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///'+basedir+'\\restAPI.db'
db.init_app(app)
# import services via blueprint
app.register_blueprint(iotAPI)
app.register_blueprint(loginService)
#logger
logger = Logger()
def create_database():
with app.app_context():
db.create_all()
if __name__ == "__main__":
app.run(debug=True)
# create_database()