-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
49 lines (32 loc) · 1.27 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python
import os
from flask import Flask, abort, request, jsonify, g, url_for
from flask_sqlalchemy import SQLAlchemy
from flask_httpauth import HTTPBasicAuth
import datetime
from flask import Flask, request, render_template_string,abort, jsonify, g, url_for
from flask_babelex import Babel
from flask_sqlalchemy import SQLAlchemy
from flask_user import current_user, login_required, roles_required, UserManager, UserMixin
# initialization
app = Flask(__name__)
app.config['SECRET_KEY'] = 'The super secret key CHANGE IN PRODUCTION'
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:root@localhost/db_name'
##Can change the library instead of pymysql and instead of local host you can input any ##production RDBMS.
app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
app.config['USER_EMAIL_SENDER_EMAIL'] = "yourmailid@domain.com"
auth = HTTPBasicAuth()
from __init__ import db
# models
from user_models.user import User
# controllers
from controllers.user_controller import user_controller
# routes
app.register_blueprint(user_controller)
@app.route('/api/resource')
@auth.login_required
def get_resource():
return jsonify({'data': 'Hello, %s!' % g.user.email})
if __name__ == '__main__':
db.create_all()
app.run(host='0.0.0.0', debug=True)