41 lines
1,015 B
Python
Executable file
41 lines
1,015 B
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
import os
|
|
import bottle
|
|
import urllib.parse
|
|
import requests
|
|
|
|
@bottle.get('/spaceapi-proxy/<schema>/<host>')
|
|
@bottle.get('/spaceapi-proxy/<schema>/<host>/')
|
|
@bottle.get('/spaceapi-proxy/<schema>/<host>/<path:path>')
|
|
def spaceapi_proxy(schema, host, path=''):
|
|
url = urllib.parse.urlunsplit((schema, host, path, '', ''))
|
|
r = requests.get(url)
|
|
return r.json()
|
|
|
|
@bottle.get('/spaceapi.json')
|
|
def index():
|
|
return bottle.static_file('spaceapi.json', root='out')
|
|
|
|
@bottle.get('/static/<path:path>')
|
|
def static(path):
|
|
return bottle.static_file(path, root='out/static')
|
|
|
|
@bottle.get('/<lang>')
|
|
def langred(lang):
|
|
bottle.redirect(f'/{lang}/')
|
|
|
|
@bottle.get('/<lang>/')
|
|
def lang(lang):
|
|
return bottle.static_file('index.html', root=os.path.join('out', lang))
|
|
|
|
@bottle.get('/<lang>/<path:path>')
|
|
def langpath(lang, path):
|
|
return bottle.static_file(path, root=os.path.join('out', lang))
|
|
|
|
@bottle.get('/')
|
|
def index():
|
|
bottle.redirect('/de/')
|
|
|
|
bottle.debug()
|
|
bottle.run()
|