Support CORS policy for create a JSON API, Use library for JWT, and adding custom error page
This commit is contained in:
parent
381d1e4541
commit
04145b89c4
@ -1,7 +1,14 @@
|
||||
def erpadir(err):
|
||||
return f'static/error/{err}.html'
|
||||
|
||||
update = {
|
||||
'server.socket_host' : "hostname" ,
|
||||
'server.socket_port' : "port" ,
|
||||
'tools.sessions.on' : True ,
|
||||
'engine.autoreload.on' : False ,
|
||||
'request.show_tracebacks' : False ,
|
||||
'server.socket_host' : "hostname" ,
|
||||
'server.socket_port' : "port" ,
|
||||
'cors.expose.on' : True ,
|
||||
'tools.sessions.on' : True ,
|
||||
'engine.autoreload.on' : False ,
|
||||
'request.show_tracebacks' : False ,
|
||||
'error_page.403' : erpadir(403) ,
|
||||
'error_page.404' : erpadir(404) ,
|
||||
'error_page.500' : erpadir(500) ,
|
||||
}
|
||||
|
2
costa.py
2
costa.py
@ -1,5 +1,6 @@
|
||||
import sys
|
||||
import cherrypy
|
||||
import cherrypy_cors
|
||||
import handler
|
||||
|
||||
from config import server
|
||||
@ -15,6 +16,7 @@ if __name__ == '__main__':
|
||||
update["server.socket_host"] = sys.argv[1]
|
||||
update["server.socket_port"] = int(sys.argv[2])
|
||||
|
||||
cherrypy_cors.install()
|
||||
cherrypy.config.update ( update )
|
||||
cherrypy.quickstart ( handler.handler(), config = dirconfig )
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import cherrypy
|
||||
import cherrypy_cors
|
||||
import json
|
||||
|
||||
import core.authentication as authentication
|
||||
@ -8,6 +9,7 @@ import config.template as pages
|
||||
|
||||
import modules.user.home as user_home
|
||||
|
||||
@cherrypy.tools.accept(media="application/json")
|
||||
class handler(pages.main):
|
||||
|
||||
def __init__(self):
|
||||
|
@ -1,6 +1,8 @@
|
||||
sudo apt-get install -y python3-pip
|
||||
pip3 install --upgrade pip
|
||||
pip3 install cherrypy
|
||||
pip3 install cherrypy-cors
|
||||
pip3 install mako
|
||||
pip3 install mysql-connector
|
||||
pip3 install bcrypt
|
||||
pip3 install pyjwt[crypto]
|
||||
|
1
static/error/403.html
Normal file
1
static/error/403.html
Normal file
@ -0,0 +1 @@
|
||||
403 Forbidden
|
1
static/error/404.html
Normal file
1
static/error/404.html
Normal file
@ -0,0 +1 @@
|
||||
404 Not found
|
1
static/error/500.html
Normal file
1
static/error/500.html
Normal file
@ -0,0 +1 @@
|
||||
500 Internal server error
|
Loading…
Reference in New Issue
Block a user