Skip to content

Commit

Permalink
This should be the only edits to Empire's core code.
Browse files Browse the repository at this point in the history
Every other part of EmpirePanel should be web resources living in /static/
  • Loading branch information
pierce403 committed Jan 9, 2017
1 parent 65b15a9 commit b01b8de
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions empire
Expand Up @@ -150,7 +150,7 @@ def start_restful_api(startEmpire=False, suppress=False, username=None, password
port - port to start the API on, defaults to 1337 ;)
"""

app = Flask(__name__)
app = Flask(__name__,static_url_path='/static')

conn = database_connect()

Expand Down Expand Up @@ -206,7 +206,8 @@ def start_restful_api(startEmpire=False, suppress=False, username=None, password
# validate API token before every request except for the login URI
@app.before_request
def check_token():
if request.path != '/api/admin/login':
if request.path not in ['/api/admin/login','/']:
if not request.path.startswith('/static/'):
token = request.args.get('token')
if (not token) or (not tokenAllowed.match(token)):
return make_response('', 401)
Expand All @@ -223,6 +224,12 @@ def start_restful_api(startEmpire=False, suppress=False, username=None, password
def not_found(error):
return make_response(jsonify( { 'error': 'Not found' } ), 404)

@app.route('/', methods=['GET'])
def index():
"""
Presents the EmpirePanel web interface.
"""
return open('static/index.html').read()

@app.route('/api/version', methods=['GET'])
def get_version():
Expand Down
1 change: 1 addition & 0 deletions static/index.html
@@ -0,0 +1 @@
hello

0 comments on commit b01b8de

Please sign in to comment.