2020-08-12 22:21:11 +00:00
|
|
|
"""Onionr - Private P2P Communication
|
2019-07-01 20:38:55 +00:00
|
|
|
|
2020-08-12 22:21:11 +00:00
|
|
|
Register static file routes
|
|
|
|
"""
|
|
|
|
import os
|
|
|
|
import mimetypes
|
|
|
|
from flask import Blueprint, send_from_directory
|
|
|
|
"""
|
2019-07-01 20:38:55 +00:00
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2020-08-12 22:21:11 +00:00
|
|
|
"""
|
|
|
|
|
2019-07-01 20:38:55 +00:00
|
|
|
|
2019-08-28 02:46:14 +00:00
|
|
|
# Was having some mime type issues on windows, this appeared to fix it.
|
|
|
|
# we have no-sniff set, so if the mime types are invalid sripts can't load.
|
|
|
|
mimetypes.add_type('application/javascript', '.js')
|
|
|
|
mimetypes.add_type('text/css', '.css')
|
|
|
|
|
2019-07-01 20:38:55 +00:00
|
|
|
static_files_bp = Blueprint('staticfiles', __name__)
|
|
|
|
|
2020-08-12 22:21:11 +00:00
|
|
|
# should be set to onionr install directory from onionr startup
|
|
|
|
root = os.path.dirname(os.path.realpath(__file__)) + \
|
|
|
|
'/../../../static-data/www/'
|
|
|
|
|
2019-07-12 18:47:50 +00:00
|
|
|
|
2019-10-08 21:14:30 +00:00
|
|
|
@static_files_bp.route('/onboarding/', endpoint='onboardingIndex')
|
|
|
|
def onboard():
|
|
|
|
return send_from_directory(f'{root}onboarding/', "index.html")
|
|
|
|
|
2020-08-12 22:21:11 +00:00
|
|
|
|
2019-10-08 21:14:30 +00:00
|
|
|
@static_files_bp.route('/onboarding/<path:path>', endpoint='onboarding')
|
|
|
|
def onboard_files(path):
|
|
|
|
return send_from_directory(f'{root}onboarding/', path)
|
|
|
|
|
2020-08-12 22:21:11 +00:00
|
|
|
|
2019-07-01 20:38:55 +00:00
|
|
|
@static_files_bp.route('/friends/<path:path>', endpoint='friends')
|
|
|
|
def loadContacts(path):
|
2019-07-12 18:47:50 +00:00
|
|
|
return send_from_directory(root + 'friends/', path)
|
2019-07-01 20:38:55 +00:00
|
|
|
|
2020-08-12 22:21:11 +00:00
|
|
|
|
2019-07-01 20:38:55 +00:00
|
|
|
@static_files_bp.route('/friends/', endpoint='friendsindex')
|
|
|
|
def loadContacts():
|
2019-07-12 18:47:50 +00:00
|
|
|
return send_from_directory(root + 'friends/', 'index.html')
|
2019-07-01 20:38:55 +00:00
|
|
|
|
2020-08-12 22:21:11 +00:00
|
|
|
|
2019-07-01 20:38:55 +00:00
|
|
|
@static_files_bp.route('/profiles/<path:path>', endpoint='profiles')
|
|
|
|
def loadContacts(path):
|
2019-07-12 18:47:50 +00:00
|
|
|
return send_from_directory(root + 'profiles/', path)
|
2019-07-01 20:38:55 +00:00
|
|
|
|
2020-08-12 22:21:11 +00:00
|
|
|
|
2019-07-01 20:38:55 +00:00
|
|
|
@static_files_bp.route('/profiles/', endpoint='profilesindex')
|
|
|
|
def loadContacts():
|
2019-07-12 18:47:50 +00:00
|
|
|
return send_from_directory(root + 'profiles/', 'index.html')
|
2019-07-01 20:38:55 +00:00
|
|
|
|
2020-08-12 22:21:11 +00:00
|
|
|
|
|
|
|
|
2019-07-01 20:38:55 +00:00
|
|
|
@static_files_bp.route('/shared/<path:path>', endpoint='sharedContent')
|
|
|
|
def sharedContent(path):
|
2019-07-12 18:47:50 +00:00
|
|
|
return send_from_directory(root + 'shared/', path)
|
2019-07-01 20:38:55 +00:00
|
|
|
|
2020-08-12 22:21:11 +00:00
|
|
|
|
2019-07-01 20:38:55 +00:00
|
|
|
@static_files_bp.route('/', endpoint='onionrhome')
|
|
|
|
def hello():
|
|
|
|
# ui home
|
2019-07-12 18:47:50 +00:00
|
|
|
return send_from_directory(root + 'private/', 'index.html')
|
2019-07-01 20:38:55 +00:00
|
|
|
|
2020-08-12 22:21:11 +00:00
|
|
|
|
2019-07-01 20:38:55 +00:00
|
|
|
@static_files_bp.route('/private/<path:path>', endpoint='homedata')
|
|
|
|
def homedata(path):
|
2019-07-12 18:47:50 +00:00
|
|
|
return send_from_directory(root + 'private/', path)
|