-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
30 lines (22 loc) · 859 Bytes
/
server.py
File metadata and controls
30 lines (22 loc) · 859 Bytes
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
# !flask/bin/python
from flask import Flask, jsonify, Response, request, send_from_directory
# create simple flask server
flaskInstance = Flask(__name__, static_url_path='')
# default handler
@flaskInstance.errorhandler(404)
def not_found(error):
response = jsonify({'error': error.description})
return response
@flaskInstance.route('/', methods=['GET'])
def index():
print(request.query_string)
return flaskInstance.send_static_file('index.html')
def send_css(path):
return send_from_directory('static/css', path)
@flaskInstance.route('/script/<path:path>', methods=['GET'])
def send_script(path):
return send_from_directory('static/script', path)
if __name__ == "__main__":
local_ip = raw_input("--Please input local ip:\n")
flaskInstance.run(debug=False, host=local_ip, port=5013)
print('main thread finished!')