Skip to content

Commit e8263f5

Browse files
Tomasz Boińskiroscisz
Tomasz Boiński
authored andcommitted
fix for #288
1 parent bcf0130 commit e8263f5

File tree

10 files changed

+41
-29
lines changed

10 files changed

+41
-29
lines changed

tensorhive/api/APIServer.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ def shutdown_session(exception=None):
3232
strict_validation=True)
3333
CORS(app.app)
3434
log.info('[⚙] Starting API server with {} backend'.format(API_SERVER.BACKEND))
35-
URL = 'http://{host}:{port}/{url_prefix}/ui/'.format(
35+
URL = '{schema}://{host}:{port}/{url_prefix}/ui/'.format(
36+
schema=API.URL_SCHEMA,
3637
host=API.URL_HOSTNAME,
37-
port=API_SERVER.PORT,
38+
port=API.URL_PORT,
3839
url_prefix=API.URL_PREFIX)
3940
log.info(green('[✔] API documentation (Swagger UI) available at: {}'.format(URL)))
4041
app.run(server=API_SERVER.BACKEND,

tensorhive/app/web/AppServer.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ def _inject_api_endpoint_to_app():
5050
try:
5151
web_app_json_config_path = PosixPath(__file__).parent / 'dist/static/config.json'
5252
data = {
53-
'apiPath': 'http://{}:{}/{}'.format(
53+
'apiPath': '{}://{}:{}/{}'.format(
54+
API.URL_SCHEMA,
5455
API.URL_HOSTNAME,
55-
API_SERVER.PORT,
56+
API.URL_PORT,
5657
API.URL_PREFIX),
5758
'version': tensorhive.__version__
5859
}
@@ -78,7 +79,7 @@ def start_server():
7879
'workers': APP_SERVER.WORKERS,
7980
'loglevel': APP_SERVER.LOG_LEVEL
8081
}
81-
log.info(green('[✔] Web App available at: http://{}:{}'.format(API.URL_HOSTNAME, APP_SERVER.PORT)))
82+
log.info(green('[✔] Web App available at: http://{}:{}'.format(API_SERVER.HOST, APP_SERVER.PORT)))
8283
GunicornStandaloneApplication(app, options).run()
8384
else:
8485
raise NotImplementedError('Selected backend is not supported yet.')

tensorhive/app/web/dev/build_vue/webpack.base.conf.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ module.exports = {
6060
loader: 'url-loader',
6161
query: {
6262
limit: 10000,
63-
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
63+
name: utils.assetsPath('fonts/[name].[hash:7].[ext]'),
64+
// workaround for vuejs-templates webpack issue 1266
65+
publicPath: process.env.NODE_ENV === 'production' ? '../../' : '/'
6466
}
6567
}
6668
]

tensorhive/app/web/dev/config/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = {
77
index: path.resolve(__dirname, '../../dist/index.html'),
88
assetsRoot: path.resolve(__dirname, '../../dist'),
99
assetsSubDirectory: 'static',
10-
assetsPublicPath: '/',
10+
assetsPublicPath: './',
1111
productionSourceMap: true,
1212
// Gzip off by default as many popular static hosts such as
1313
// Surge or Netlify already gzip all static assets for you.

tensorhive/app/web/dev/index.html

+21-21
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,39 @@
33
<head>
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1">
6-
<link rel="apple-touch-icon" sizes="57x57" href="/static/favicon/apple-icon-57x57.png">
7-
<link rel="apple-touch-icon" sizes="60x60" href="/static/favicon/apple-icon-60x60.png">
8-
<link rel="apple-touch-icon" sizes="72x72" href="/static/favicon/apple-icon-72x72.png">
9-
<link rel="apple-touch-icon" sizes="76x76" href="/static/favicon/apple-icon-76x76.png">
10-
<link rel="apple-touch-icon" sizes="114x114" href="/static/favicon/apple-icon-114x114.png">
11-
<link rel="apple-touch-icon" sizes="120x120" href="/static/favicon/apple-icon-120x120.png">
12-
<link rel="apple-touch-icon" sizes="144x144" href="/static/favicon/apple-icon-144x144.png">
13-
<link rel="apple-touch-icon" sizes="152x152" href="/static/favicon/apple-icon-152x152.png">
14-
<link rel="apple-touch-icon" sizes="180x180" href="/static/favicon/apple-icon-180x180.png">
15-
<link rel="icon" type="image/png" sizes="192x192" href="/static/favicon/android-icon-192x192.png">
16-
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon/favicon-32x32.png">
17-
<link rel="icon" type="image/png" sizes="96x96" href="/static/favicon/favicon-96x96.png">
18-
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon/favicon-16x16.png">
19-
<link rel="manifest" href="/static/favicon/manifest.json">
6+
<link rel="apple-touch-icon" sizes="57x57" href="./static/favicon/apple-icon-57x57.png">
7+
<link rel="apple-touch-icon" sizes="60x60" href="./static/favicon/apple-icon-60x60.png">
8+
<link rel="apple-touch-icon" sizes="72x72" href="./static/favicon/apple-icon-72x72.png">
9+
<link rel="apple-touch-icon" sizes="76x76" href="./static/favicon/apple-icon-76x76.png">
10+
<link rel="apple-touch-icon" sizes="114x114" href="./static/favicon/apple-icon-114x114.png">
11+
<link rel="apple-touch-icon" sizes="120x120" href="./static/favicon/apple-icon-120x120.png">
12+
<link rel="apple-touch-icon" sizes="144x144" href="./static/favicon/apple-icon-144x144.png">
13+
<link rel="apple-touch-icon" sizes="152x152" href="./static/favicon/apple-icon-152x152.png">
14+
<link rel="apple-touch-icon" sizes="180x180" href="./static/favicon/apple-icon-180x180.png">
15+
<link rel="icon" type="image/png" sizes="192x192" href="./static/favicon/android-icon-192x192.png">
16+
<link rel="icon" type="image/png" sizes="32x32" href="./static/favicon/favicon-32x32.png">
17+
<link rel="icon" type="image/png" sizes="96x96" href="./static/favicon/favicon-96x96.png">
18+
<link rel="icon" type="image/png" sizes="16x16" href="./static/favicon/favicon-16x16.png">
19+
<link rel="manifest" href="./static/favicon/manifest.json">
2020
<meta name="msapplication-TileColor" content="#ffffff">
21-
<meta name="msapplication-TileImage" content="/ms-icon-144x144.png">
21+
<meta name="msapplication-TileImage" content="./ms-icon-144x144.png">
2222
<meta name="theme-color" content="#ffffff">
2323
<title>TensorHive</title>
2424
<!-- css -->
25-
<link rel="stylesheet" href="/static/bootstrap/bootstrap.min.css">
25+
<link rel="stylesheet" href="./static/bootstrap/bootstrap.min.css">
2626

2727
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
2828
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css">
2929

30-
<link rel="stylesheet" href="/static/AdminLTE/AdminLTE.min.css">
31-
<link rel="stylesheet" href="/static/AdminLTE/skin-blue.min.css">
30+
<link rel="stylesheet" href="./static/AdminLTE/AdminLTE.min.css">
31+
<link rel="stylesheet" href="./static/AdminLTE/skin-blue.min.css">
3232
</head>
3333
<body class="hold-transition skin-blue sidebar-mini sidebar-collapse">
3434
<div id="root"></div>
3535

3636
<!-- built files will be auto injected. Static files below -->
37-
<script src="/static/jQuery/jQuery-2.2.0.min.js"></script>
38-
<script src="/static/bootstrap/bootstrap.min.js"></script>
39-
<script src="/static/AdminLTE/app.min.js"></script>
37+
<script src="./static/jQuery/jQuery-2.2.0.min.js"></script>
38+
<script src="./static/bootstrap/bootstrap.min.js"></script>
39+
<script src="./static/AdminLTE/app.min.js"></script>
4040
</body>
4141
</html>

tensorhive/app/web/dev/src/main.js

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ axios.get('/static/config.json').then(response => {
5454
var router = new VueRouter({
5555
routes: routes,
5656
mode: 'history',
57+
// Change it if TensorHive will run in sub context! e.g. to '/tensorhive/',
58+
base: '/',
5759
linkExactActiveClass: 'active',
5860
scrollBehavior: function (to, from, savedPosition) {
5961
return savedPosition || { x: 0, y: 0 }

tensorhive/app/web/dev/src/routes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const routes = [
1515
component: DashView,
1616
children: [
1717
{
18-
path: '/reservations_overview',
18+
path: 'reservations_overview',
1919
alias: '',
2020
component: CalendarView,
2121
name: 'Reservation Overview',

tensorhive/cli.py

+2
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ def init():
158158
else:
159159
host = '0.0.0.0'
160160
main_config.set('api', 'url_hostname', host)
161+
main_config.set('api', 'url_schema', 'http')
162+
main_config.set('api', 'url_port', '1111')
161163
with open(CONFIG_FILES.MAIN_CONFIG_PATH, 'w') as main_config_file:
162164
main_config.write(main_config_file)
163165
click.echo(green('[⚙] TensorHive will be accessible via: {}'.format(host)))

tensorhive/config.py

+2
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ def uri_for_path(path: str) -> str: # type: ignore
167167
class API:
168168
section = 'api'
169169
TITLE = config.get(section, 'title', fallback='TensorHive API')
170+
URL_SCHEMA = config.get(section, 'url_schema', fallback='http')
170171
URL_HOSTNAME = config.get(section, 'url_hostname', fallback='0.0.0.0')
172+
URL_PORT = config.get(section, 'url_port', fallback='1111')
171173
URL_PREFIX = config.get(section, 'url_prefix', fallback='api')
172174
SPEC_FILE = config.get(section, 'spec_file', fallback='api_specification.yml')
173175
IMPL_LOCATION = config.get(section, 'impl_location', fallback='tensorhive.api.controllers')

tensorhive/main_config.ini

+2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ path = ~/.config/TensorHive/database.sqlite
1010

1111
[api]
1212
title = TensorHive API
13+
url_schema = http
1314
url_hostname = 0.0.0.0
15+
url_port = 1111
1416
url_prefix = api
1517
spec_file = api_specification.yml
1618
impl_location = tensorhive.api.controllers

0 commit comments

Comments
 (0)