Added a separate wsgi app for the modules
This commit is contained in:
parent
d744e87c4d
commit
9332c4b673
5 changed files with 40 additions and 28 deletions
|
|
@ -1,6 +1,9 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from paramecio.index import app, run_app
|
||||
from paramecio.wsgiapp import app
|
||||
from paramecio.index import run_app
|
||||
|
||||
application=app
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_app(app)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ from paramecio.cromosoma.webmodel import WebModel
|
|||
from paramecio.citoplasma.datetime import set_timezone
|
||||
from itsdangerous import JSONWebSignatureSerializer
|
||||
from paramecio.citoplasma.keyutils import create_key_encrypt, create_key_encrypt_256, create_key
|
||||
from paramecio.wsgiapp import app
|
||||
#from paramecio.citoplasma.sessions import generate_session
|
||||
|
||||
#Prepare links for static.
|
||||
|
|
@ -18,7 +19,7 @@ workdir=os.getcwd()
|
|||
arr_module_path={}
|
||||
if config.yes_static==True:
|
||||
|
||||
@route('/media/<filename:path>')
|
||||
@app.route('/media/<filename:path>')
|
||||
def send_static(filename):
|
||||
mimetype=guess_type(workdir+'/themes/'+config.theme+'/media/'+filename)
|
||||
|
||||
|
|
@ -26,7 +27,7 @@ if config.yes_static==True:
|
|||
|
||||
#def add_func_static_module(module):
|
||||
|
||||
@route('/mediafrom/<module>/<filename:path>')
|
||||
@app.route('/mediafrom/<module>/<filename:path>')
|
||||
def send_static_module(module, filename):
|
||||
|
||||
path_module=arr_module_path[module]+'/media/'
|
||||
|
|
@ -84,7 +85,7 @@ if config.ssl==True:
|
|||
|
||||
#Prepare app
|
||||
|
||||
app = application = default_app()
|
||||
application=app
|
||||
|
||||
#app.add_hook('before_request', print_memory)
|
||||
|
||||
|
|
@ -166,16 +167,20 @@ if config.session_enabled==True:
|
|||
|
||||
# Clean last slash
|
||||
|
||||
@hook('before_request')
|
||||
@app.hook('before_request')
|
||||
def strip_path():
|
||||
request.environ['PATH_INFO'] = request.environ['PATH_INFO'].rstrip('/')
|
||||
|
||||
# Set error screen if not debug setted
|
||||
|
||||
if config.debug==False:
|
||||
@error(404)
|
||||
@app.error(404)
|
||||
def error404(error):
|
||||
return 'Error: page not found'
|
||||
else:
|
||||
@app.error(500)
|
||||
def error500(error):
|
||||
return error
|
||||
|
||||
set_timezone()
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ from time import time
|
|||
from paramecio.citoplasma.keyutils import create_key_encrypt, create_key_encrypt_256, create_key
|
||||
from paramecio.citoplasma.sendmail import SendMail
|
||||
from os import path
|
||||
from paramecio.wsgiapp import app
|
||||
import copy
|
||||
|
||||
#from citoplasma.login import LoginClass
|
||||
|
|
@ -57,11 +58,11 @@ for k, v in menu.items():
|
|||
|
||||
#print(d)
|
||||
|
||||
@get('/'+config.admin_folder)
|
||||
@get('/'+config.admin_folder+'/<module>')
|
||||
@post('/'+config.admin_folder+'/<module>')
|
||||
@get('/'+config.admin_folder+'/<module>/<submodule>')
|
||||
@post('/'+config.admin_folder+'/<module>/<submodule>')
|
||||
@app.get('/'+config.admin_folder)
|
||||
@app.get('/'+config.admin_folder+'/<module>')
|
||||
@app.post('/'+config.admin_folder+'/<module>')
|
||||
@app.get('/'+config.admin_folder+'/<module>/<submodule>')
|
||||
@app.post('/'+config.admin_folder+'/<module>/<submodule>')
|
||||
def home(module='', submodule=''):
|
||||
|
||||
# A simple boolean used for show or not the code of admin module in standard template
|
||||
|
|
@ -231,7 +232,7 @@ def home(module='', submodule=''):
|
|||
|
||||
return ""
|
||||
|
||||
@post('/'+config.admin_folder+'/login')
|
||||
@app.post('/'+config.admin_folder+'/login')
|
||||
def login():
|
||||
|
||||
connection=WebModel.connection()
|
||||
|
|
@ -343,7 +344,7 @@ def login():
|
|||
return {'error': 1, 'csrf_token': s['csrf_token']}
|
||||
|
||||
|
||||
@post('/'+config.admin_folder+'/register')
|
||||
@app.post('/'+config.admin_folder+'/register')
|
||||
def register():
|
||||
|
||||
getpostfiles=GetPostFiles()
|
||||
|
|
@ -404,7 +405,7 @@ def register():
|
|||
|
||||
return {'error': 1}
|
||||
|
||||
@get('/'+config.admin_folder+'/logout')
|
||||
@app.get('/'+config.admin_folder+'/logout')
|
||||
def logout():
|
||||
|
||||
s=get_session()
|
||||
|
|
@ -427,7 +428,7 @@ def logout():
|
|||
|
||||
redirect(make_url(config.admin_folder))
|
||||
|
||||
@get('/'+config.admin_folder+'/recovery_password')
|
||||
@app.get('/'+config.admin_folder+'/recovery_password')
|
||||
def recovery_password():
|
||||
|
||||
t=PTemplate(env)
|
||||
|
|
@ -446,7 +447,7 @@ def recovery_password():
|
|||
connection.close()
|
||||
return t.render_template('admin/recovery.phtml', forms=forms)
|
||||
|
||||
@post('/'+config.admin_folder+'/recovery_password')
|
||||
@app.post('/'+config.admin_folder+'/recovery_password')
|
||||
def send_password():
|
||||
|
||||
connection=WebModel.connection()
|
||||
|
|
@ -503,13 +504,13 @@ def send_password():
|
|||
return {'email': '', 'error': 0}
|
||||
|
||||
|
||||
@get('/'+config.admin_folder+'/check_token')
|
||||
@app.get('/'+config.admin_folder+'/check_token')
|
||||
def check_token():
|
||||
t=PTemplate(env)
|
||||
|
||||
return t.render_template('admin/check_token.phtml')
|
||||
|
||||
@post('/'+config.admin_folder+'/check_token')
|
||||
@app.post('/'+config.admin_folder+'/check_token')
|
||||
def check_code_token():
|
||||
|
||||
t=PTemplate(env)
|
||||
|
|
|
|||
|
|
@ -2,31 +2,29 @@
|
|||
|
||||
from paramecio.citoplasma.mtemplates import PTemplate, env_theme
|
||||
from paramecio.citoplasma.urls import make_url
|
||||
from bottle import route, request
|
||||
from paramecio.wsgiapp import app
|
||||
from settings import config
|
||||
|
||||
#t=ptemplate(__file__)
|
||||
env=env_theme(__file__)
|
||||
|
||||
@route('/welcome')
|
||||
def home():
|
||||
t=PTemplate(env)
|
||||
|
||||
t=PTemplate(env)
|
||||
@app.route('/welcome')
|
||||
def home():
|
||||
|
||||
return t.render_template('welcome.html', title="Welcome to Paramecio!!!", content="The simple web framework writed in Python3!!!")
|
||||
|
||||
@route('/welcome/<id:int>')
|
||||
@app.route('/welcome/<id:int>')
|
||||
def page(id):
|
||||
|
||||
t=PTemplate(env)
|
||||
|
||||
return t.render_template('index.html', title="A simple example of a page", id=id, value=request.query.value)
|
||||
|
||||
@route('/welcome/test/<id:int>')
|
||||
@app.route('/welcome/test/<id:int>')
|
||||
def test(id):
|
||||
|
||||
return make_url('welcome/test/5', {'ohmygod': 'This is gooood', 'shutup':'Shut up!!'})
|
||||
|
||||
if config.default_module=="welcome":
|
||||
|
||||
home = route("/")(home)
|
||||
home = app.route("/")(home)
|
||||
|
|
|
|||
5
paramecio/wsgiapp.py
Normal file
5
paramecio/wsgiapp.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
from bottle import Bottle
|
||||
|
||||
app=Bottle()
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue