-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
45 lines (40 loc) · 1.47 KB
/
run.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
#!/usr/bin/python3
import os
from .app import create_app
# from flask_cors import CORS, cross_origin
from flask import render_template, flash, redirect, url_for, jsonify, request, Response, abort
from .app.models.models import *
# db.create_all()
config_name = os.getenv('FLASK_CONFIG')
app = create_app(config_name)
print('run.py') #, app.config)
# CORS(app)
# prod
# cors = CORS(app
# , resources={r"/*": {"origins": "*"}}
# ,expose_headers='Authorization',
# allow_headers=["Content-Type", "Authorization", "Access-Control-Allow-Credentials"],
# supports_credentials=True)
# app.config['CORS_HEADERS'] = "Content-Type", "Authorization", "Access-Control-Allow-Credentials"
@app.before_first_request
def create_tables():
db.create_all()
# @app.before_request
# def authorize_token():
# print('before', request)
# print(request.method)
# print(request.headers)
# print('referer', request.headers['Referer'])
# if request.endpoint == 'test':
# try:
# if request.method != 'OPTIONS': # <-- required
# auth_header = request.headers.get("Authorization")
# if "Bearer" in auth_header:
# token = auth_header.split(' ')[1]
# if token != '12345678':
# raise ValueError('Authorization failed.')
# except Exception as e:
# return "401 Unauthorized\n{}\n\n".format(e), 401
if __name__ == '__main__':
# app.run()
print(544)