Skip to content
Snippets Groups Projects
Commit 1916a709 authored by FarawayVision's avatar FarawayVision
Browse files

Add python script to host server offline w/ bottle

parent b4434598
No related branches found
No related tags found
No related merge requests found
from bottle import get, post, request, response, redirect, route, run, static_file
import os
import os.path as osp
host='localhost'
port=5000
@route('/')
def redir_index():
return redirect('/index.html')
ext_mimetypes = {
'.png': 'image/png',
'.jpg': 'image/jpeg',
'.css': 'text/css',
'.js': 'text/javascript',
'.html': 'text/html',
'.xml': 'application/xml'
}
@route('/<filename:path>')
def statics(filename):
ext = osp.splitext(filename)[-1]
try:
mimetype = ext_mimetypes[ext]
except KeyError:
mimetype = 'text/plain'
return static_file(filename, root=os.getcwd(), mimetype=mimetype)
run(host=host, port=port, reloader=True)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment