|
|
from flask import Flask |
|
|
from flask_cors import CORS |
|
|
|
|
|
def create_app(): |
|
|
app = Flask(__name__, |
|
|
static_folder='static', |
|
|
template_folder='templates') |
|
|
|
|
|
|
|
|
CORS(app, resources={ |
|
|
r"/*": { |
|
|
"origins": [ |
|
|
r"https://.*\.hf\.space", |
|
|
"https://<your-username>.github.io", |
|
|
"https://www.<your-domain>.com", |
|
|
"http://localhost:5000", |
|
|
"http://127.0.0.1:5000", |
|
|
], |
|
|
"methods": ["GET", "POST", "OPTIONS"], |
|
|
"allow_headers": ["Content-Type"] |
|
|
} |
|
|
}) |
|
|
|
|
|
|
|
|
@app.after_request |
|
|
def add_security_headers(response): |
|
|
|
|
|
response.headers['X-Content-Type-Options'] = 'nosniff' |
|
|
|
|
|
response.headers['X-XSS-Protection'] = '1; mode=block' |
|
|
return response |
|
|
|
|
|
|
|
|
from app.routes import main |
|
|
app.register_blueprint(main) |
|
|
|
|
|
return app |