-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
34 lines (27 loc) · 965 Bytes
/
main.py
File metadata and controls
34 lines (27 loc) · 965 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
from api import bp, api
from flask_cors import CORS, cross_origin
from flask import Flask, request
from api_routes import search_ns
config = {
'ORIGINS': [
'http://localhost:3000/'
]
}
app = Flask(__name__, instance_relative_config=True)
cors = CORS(app, resources={'/*': {'origins': config['ORIGINS']}})
app.register_blueprint(bp)
app.config['CORS_HEADERS'] = 'Content-Type'
app.config.from_mapping(SECRET_KEY='dev')
app.config['DEBUG'] = True
app.config['RESTPLUS_VALIDATE'] = True
app.config['SWAGGER_UI_DOC_EXPANSION'] = 'list'
cross_origin(automatic_options=True)
api.add_namespace(search_ns)
@app.after_request
def after_request(response):
response.headers.add('Access-Control-Allow-Origin', '*')
response.headers.add('Access-Control-Allow-Methods', 'POST')
response.headers.add('Access-Control-Allow-Headers', 'Content-Type')
return response
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000, debug=True)