Fix in app loading
This commit is contained in:
parent
6ada28d39b
commit
fc70da5e20
2 changed files with 52 additions and 29 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
from settings import config
|
from settings import config
|
||||||
from bottle import request, response, HTTPResponse
|
from bottle import request, response, HTTPResponse
|
||||||
|
import urllib.parse
|
||||||
|
|
||||||
# A modified version of bottle url for don't need set x-proxy shit for redirect...
|
# A modified version of bottle url for don't need set x-proxy shit for redirect...
|
||||||
|
|
||||||
|
|
@ -33,7 +34,8 @@ def make_url(path, query_args={}):
|
||||||
|
|
||||||
if len(query_args)>0:
|
if len(query_args)>0:
|
||||||
|
|
||||||
get_query='?'+"&".join( [x+'='+y for x,y in query_args.items()] )
|
#get_query='?'+"&".join( [x+'='+y for x,y in query_args.items()] )
|
||||||
|
get_query='?'+urllib.parse.urlencode(query_args)
|
||||||
|
|
||||||
return config.base_url+path+get_query
|
return config.base_url+path+get_query
|
||||||
|
|
||||||
|
|
@ -48,7 +50,29 @@ def add_get_parameters(url, **args):
|
||||||
if url.find('?')==-1:
|
if url.find('?')==-1:
|
||||||
added_url='?'
|
added_url='?'
|
||||||
|
|
||||||
return url+added_url+"&".join( [x+'='+str(y) for x,y in args.items()] )
|
get_query=urllib.parse.urlencode(args)
|
||||||
|
|
||||||
|
return url+added_url+get_query
|
||||||
|
|
||||||
|
def make_external_url(path, query_args={}):
|
||||||
|
|
||||||
|
"""
|
||||||
|
This is a method for create urls for external systems
|
||||||
|
|
||||||
|
Keyword arguments:
|
||||||
|
path -- The base url of the url
|
||||||
|
query_args -- a ser of get variables for add to url
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
get_query=''
|
||||||
|
|
||||||
|
if len(query_args)>0:
|
||||||
|
|
||||||
|
#get_query='?'+"&".join( [x+'='+y for x,y in query_args.items()] )
|
||||||
|
get_query='?'+urllib.parse.urlencode(query_args)
|
||||||
|
|
||||||
|
return path+get_query
|
||||||
|
|
||||||
def get_actual_url():
|
def get_actual_url():
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,32 @@ debug(config.debug)
|
||||||
|
|
||||||
application=app
|
application=app
|
||||||
|
|
||||||
|
# Load modules
|
||||||
|
|
||||||
|
try:
|
||||||
|
|
||||||
|
from settings import modules
|
||||||
|
|
||||||
|
prepare_app()
|
||||||
|
|
||||||
|
except:
|
||||||
|
|
||||||
|
@app.route('/')
|
||||||
|
def catch_errors(all='/'):
|
||||||
|
try:
|
||||||
|
from pathlib import Path
|
||||||
|
from settings import modules
|
||||||
|
import time
|
||||||
|
prepare_app()
|
||||||
|
p=Path('index.py')
|
||||||
|
p.touch()
|
||||||
|
time.sleep(1)
|
||||||
|
except:
|
||||||
|
raise
|
||||||
|
|
||||||
|
redirect(request.url)
|
||||||
|
catch_errors=app.route('/<all:path>')(catch_errors)
|
||||||
|
|
||||||
# Prepare static routes
|
# Prepare static routes
|
||||||
|
|
||||||
if config.yes_static==True:
|
if config.yes_static==True:
|
||||||
|
|
@ -113,33 +139,6 @@ if config.yes_static==True:
|
||||||
mimetype=guess_type(path_module+'/'+filename)
|
mimetype=guess_type(path_module+'/'+filename)
|
||||||
return static_file(filename, root=path_module, mimetype=mimetype[0])
|
return static_file(filename, root=path_module, mimetype=mimetype[0])
|
||||||
|
|
||||||
# Load modules
|
|
||||||
|
|
||||||
try:
|
|
||||||
|
|
||||||
from settings import modules
|
|
||||||
|
|
||||||
prepare_app()
|
|
||||||
|
|
||||||
except:
|
|
||||||
|
|
||||||
@app.route('/')
|
|
||||||
def catch_errors(all='/'):
|
|
||||||
try:
|
|
||||||
from pathlib import Path
|
|
||||||
from settings import modules
|
|
||||||
import time
|
|
||||||
prepare_app()
|
|
||||||
p=Path('index.py')
|
|
||||||
p.touch()
|
|
||||||
time.sleep(1)
|
|
||||||
except:
|
|
||||||
raise
|
|
||||||
|
|
||||||
redirect(request.url)
|
|
||||||
catch_errors=app.route('/<all:path>')(catch_errors)
|
|
||||||
|
|
||||||
|
|
||||||
def run_app(app):
|
def run_app(app):
|
||||||
if config.server_used!='cherrypy':
|
if config.server_used!='cherrypy':
|
||||||
run(app=app, host=config.host, server=config.server_used, port=config.port, debug=config.debug, reloader=config.reloader)
|
run(app=app, host=config.host, server=config.server_used, port=config.port, debug=config.debug, reloader=config.reloader)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue