forked from TrinityComputers/Flask-SQLALchemy-RESTFUL-API
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
29 lines (20 loc) · 832 Bytes
/
__init__.py
File metadata and controls
29 lines (20 loc) · 832 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
from flask import Flask, Response
class MyResponse(Response):
default_mimetype = 'application/xml'
# http://flask.pocoo.org/docs/0.10/patterns/appfactories/
def create_app(config_filename):
app = Flask(__name__)
app.config.from_object(config_filename)
app.response_class = MyResponse
from app.models import db
db.init_app(app)
# Blueprints
from app.users.views import users
app.register_blueprint(users, url_prefix='/api/v1/users')
@app.after_request
def after_request(response):
response.headers.add('Access-Control-Allow-Origin', '*')
response.headers.add('Access-Control-Allow-Headers', 'Content-Type,Authorization')
response.headers.add('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE')
return response
return app