Skip to content

Commit

Permalink
add basic and basic_yaml in webserver
Browse files Browse the repository at this point in the history
  • Loading branch information
knorth55 authored and k-okada committed Oct 28, 2021
1 parent 37ff212 commit ff3e4e7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions launch/roswww.launch
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
<arg name="webpath" default="www"/> <!-- package webroot -->
<arg name="cached" default="true"/>
<arg name="single_package" default=""/>
<arg name="basic" default="false"/>

<arg name="port" default="8085"/>
<arg name="start_port" default="$(arg port)" />
<arg name="end_port" default="$(arg port)" />

<node pkg="roswww" type="webserver.py" name="$(arg name)"
args="--name $(arg name) --webpath $(arg webpath) --cached $(arg cached)
--basic $(arg basic)
--single_package=$(arg single_package)
--port $(arg port) --start_port $(arg start_port) --end_port $(arg end_port)" />
</launch>
11 changes: 8 additions & 3 deletions script/webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,22 @@ def parse_argument(argv):
parser.add_argument('-w', '--webpath', default='www', help='package relative path to web pages')
parser.add_argument('-s', '--single_package', default='', help='package name for single package mode')
parser.add_argument('--cached', default='true', help='static file is cached')
parser.add_argument('--basic', default='false', help='enable basic authentication')
parser.add_argument('--basic-yaml', default=None, help='basic key yaml file path')
parser.add_argument('--start_port', default=8000, type=int, help='setting up port scan range')
parser.add_argument('--end_port', default=9000, type=int, help='setting up port scan range')

parsed_args = parser.parse_args(argv)
cached = False if parsed_args.cached in [0, False, 'false', 'False'] else True
return parsed_args.name, parsed_args.webpath, (parsed_args.port, parsed_args.start_port, parsed_args.end_port), cached, parsed_args.single_package
basic = True if parsed_args.basic in [1, True, 'true', 'True'] else False
basic_yaml = parsed_args.basic_yaml
return parsed_args.name, parsed_args.webpath, (parsed_args.port, parsed_args.start_port, parsed_args.end_port), cached, parsed_args.single_package, basic, basic_yaml



if __name__ == '__main__':
rospy.init_node("webserver", disable_signals=True)
name, webpath, port, cached, single = parse_argument(rospy.myargv()[1:])
webserver = roswww.ROSWWWServer(name, webpath, port, cached, single_package=single)
name, webpath, port, cached, single, basic, basic_yaml = parse_argument(rospy.myargv()[1:])
webserver = roswww.ROSWWWServer(name, webpath, port, cached, single_package=single, basic=basic, basic_yaml=basic_yaml)
webserver.loginfo("Initialised")
webserver.spin()

0 comments on commit ff3e4e7

Please sign in to comment.