Skip to content

Commit e782c9d

Browse files
author
zhangjie
committed
change something
1 parent b3476e0 commit e782c9d

File tree

6 files changed

+15
-2
lines changed

6 files changed

+15
-2
lines changed

api/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
def create_app():
14-
app = Flask(__name__)
14+
app = Flask(__name__, static_folder=Config.STATIC_FOLDER, static_url_path='')
1515
app.config.from_object(Config)
1616

1717
Config.init_app(app)

api/static_file.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from flask import redirect
2+
3+
from . import app
4+
5+
6+
@app.route('/')
7+
def index():
8+
return redirect('/index.html')

api/users/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
api_user = Blueprint('users', __name__)
99

10-
api.add_resource(User, '/user')
10+
api.add_resource(User, '/user', endpoint='user')
1111

1212
api.init_app(api_user)
1313

config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ class Config:
4848
SQLALCHEMY_TRACK_MODIFICATIONS = False
4949
SQLALCHEMY_ECHO = False
5050

51+
MY_ROOT_DIR = MY_ROOT_DIR
52+
STATIC_FOLDER = os.path.join(MY_ROOT_DIR, 'static')
53+
5154
@staticmethod
5255
def init_app(app):
5356
pass

manage.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from api import app
66
from api.models import *
7+
from api.static_file import *
78

89
from init_data import insert_admin
910

static/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hello

0 commit comments

Comments
 (0)