mirror of
https://github.com/CopterExpress/clover.git
synced 2026-06-10 03:24:32 +00:00
Simple web-server node for serving Clever interface
This commit is contained in:
28
clever/src/web_server.py
Normal file
28
clever/src/web_server.py
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import rospy
|
||||
from flask import Flask, send_from_directory, send_file
|
||||
|
||||
|
||||
rospy.init_node('web_server', disable_signals=True)
|
||||
|
||||
|
||||
port = rospy.get_param('~port', 8080)
|
||||
host = rospy.get_param('~host', '0.0.0.0')
|
||||
serve_path = rospy.get_param('~path')
|
||||
app = Flask(__name__)
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def serve_index():
|
||||
return send_from_directory(serve_path, 'index.html')
|
||||
|
||||
|
||||
@app.route('/<path:path>')
|
||||
def serve_static(path):
|
||||
print serve_path, path
|
||||
return send_from_directory(serve_path, path)
|
||||
|
||||
|
||||
rospy.loginfo('Serving on %s:%s', host, port)
|
||||
app.run(host=host, port=port, threaded=True)
|
||||
Reference in New Issue
Block a user