Merge branch 'matousek' of https://bastart.spoton.cz/git/spoton/cherrypy_sqlite_restapi into ventil
This commit is contained in:
BIN
main/modules/__pycache__/create.cpython-37.pyc
Normal file
BIN
main/modules/__pycache__/create.cpython-37.pyc
Normal file
Binary file not shown.
BIN
main/modules/__pycache__/delete.cpython-37.pyc
Normal file
BIN
main/modules/__pycache__/delete.cpython-37.pyc
Normal file
Binary file not shown.
BIN
main/modules/__pycache__/drop.cpython-37.pyc
Normal file
BIN
main/modules/__pycache__/drop.cpython-37.pyc
Normal file
Binary file not shown.
BIN
main/modules/__pycache__/index.cpython-37.pyc
Normal file
BIN
main/modules/__pycache__/index.cpython-37.pyc
Normal file
Binary file not shown.
BIN
main/modules/__pycache__/insert.cpython-37.pyc
Normal file
BIN
main/modules/__pycache__/insert.cpython-37.pyc
Normal file
Binary file not shown.
BIN
main/modules/__pycache__/select.cpython-37.pyc
Normal file
BIN
main/modules/__pycache__/select.cpython-37.pyc
Normal file
Binary file not shown.
13
main/modules/create.py
Normal file
13
main/modules/create.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import cherrypy
|
||||||
|
|
||||||
|
|
||||||
|
class create(object):
|
||||||
|
@cherrypy.expose
|
||||||
|
def index(self):
|
||||||
|
''' Method for open specific html file
|
||||||
|
and change it'''
|
||||||
|
with open('templates/create.html') as fh:
|
||||||
|
index_f = fh.read()
|
||||||
|
result = index_f.format(_title='create_strana', _heading='create')
|
||||||
|
fh.close()
|
||||||
|
return result
|
||||||
13
main/modules/delete.py
Normal file
13
main/modules/delete.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import cherrypy
|
||||||
|
|
||||||
|
|
||||||
|
class delete(object):
|
||||||
|
@cherrypy.expose
|
||||||
|
def index(self):
|
||||||
|
''' Method for open specific html file
|
||||||
|
and change it'''
|
||||||
|
with open('templates/delete.html') as fh:
|
||||||
|
index_f = fh.read()
|
||||||
|
result = index_f.format(_title='delete_strana', _heading='delete')
|
||||||
|
fh.close()
|
||||||
|
return result
|
||||||
13
main/modules/drop.py
Normal file
13
main/modules/drop.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import cherrypy
|
||||||
|
|
||||||
|
|
||||||
|
class drop(object):
|
||||||
|
@cherrypy.expose
|
||||||
|
def index(self):
|
||||||
|
''' Method for open specific html file
|
||||||
|
and change it'''
|
||||||
|
with open('templates/drop.html') as fh:
|
||||||
|
index_f = fh.read()
|
||||||
|
result = index_f.format(_title='drop_strana', _heading='drop')
|
||||||
|
fh.close()
|
||||||
|
return result
|
||||||
13
main/modules/index.py
Normal file
13
main/modules/index.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import cherrypy
|
||||||
|
|
||||||
|
|
||||||
|
class wellcome(object):
|
||||||
|
@cherrypy.expose
|
||||||
|
def index(self):
|
||||||
|
''' Method for open specific html file
|
||||||
|
and change it'''
|
||||||
|
with open('templates/index.html') as fh:
|
||||||
|
index_f = fh.read()
|
||||||
|
result = index_f.format(_title='Titulni_strana', _heading='Vítejte!')
|
||||||
|
fh.close()
|
||||||
|
return result
|
||||||
13
main/modules/insert.py
Normal file
13
main/modules/insert.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import cherrypy
|
||||||
|
|
||||||
|
|
||||||
|
class insert(object):
|
||||||
|
@cherrypy.expose
|
||||||
|
def index(self):
|
||||||
|
''' Method for open specific html file
|
||||||
|
and change it'''
|
||||||
|
with open('templates/insert.html') as fh:
|
||||||
|
index_f = fh.read()
|
||||||
|
result = index_f.format(_title='insert_strana', _heading='insert')
|
||||||
|
fh.close()
|
||||||
|
return result
|
||||||
13
main/modules/select.py
Normal file
13
main/modules/select.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import cherrypy
|
||||||
|
|
||||||
|
|
||||||
|
class select(object):
|
||||||
|
@cherrypy.expose
|
||||||
|
def index(self):
|
||||||
|
''' Method for open specific html file
|
||||||
|
and change it'''
|
||||||
|
with open('templates/select.html') as fh:
|
||||||
|
index_f = fh.read()
|
||||||
|
result = index_f.format(_title='select_strana', _heading='select')
|
||||||
|
fh.close()
|
||||||
|
return result
|
||||||
59
main/server.py
Normal file
59
main/server.py
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
import cherrypy
|
||||||
|
import os
|
||||||
|
|
||||||
|
from modules import select
|
||||||
|
from modules import delete
|
||||||
|
from modules import insert
|
||||||
|
from modules import create
|
||||||
|
from modules import drop
|
||||||
|
from modules import index
|
||||||
|
|
||||||
|
SCRIPT_PATH = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
|
||||||
|
|
||||||
|
class main_server_loop(object):
|
||||||
|
''' Main class for start cherrypy server
|
||||||
|
|
||||||
|
Settings for server socket port and how are sub-modules
|
||||||
|
called and mounted to their respective paths
|
||||||
|
|
||||||
|
Args:
|
||||||
|
*None*
|
||||||
|
|
||||||
|
Sets:
|
||||||
|
*conf:* dict(), per-application configuration
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
*N/A*
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
*Exception* Server is unable to start
|
||||||
|
|
||||||
|
'''
|
||||||
|
|
||||||
|
cherrypy.config.update({'server.socket_port': 80})
|
||||||
|
conf = {
|
||||||
|
'/': {
|
||||||
|
'tools.sessions.on': True,
|
||||||
|
'tools.staticdir.root': os.path.abspath(SCRIPT_PATH + '/')
|
||||||
|
},
|
||||||
|
'/static': {
|
||||||
|
'tools.staticdir.on': True,
|
||||||
|
'tools.staticdir.dir': './static'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cherrypy.tree.mount(index.wellcome(), "/", conf)
|
||||||
|
cherrypy.tree.mount(select.select(), "/select", conf)
|
||||||
|
cherrypy.tree.mount(delete.delete(), "/delete", conf)
|
||||||
|
cherrypy.tree.mount(insert.insert(), "/insert", conf)
|
||||||
|
cherrypy.tree.mount(create.create(), "/create", conf)
|
||||||
|
cherrypy.tree.mount(drop.drop(), "/drop", conf)
|
||||||
|
cherrypy.engine.start()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
try:
|
||||||
|
main_server_loop()
|
||||||
|
except Exception as e:
|
||||||
|
raise e
|
||||||
10
main/templates/create.html
Normal file
10
main/templates/create.html
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>{_title}</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<h1>{_heading}</h1>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
10
main/templates/delete.html
Normal file
10
main/templates/delete.html
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>{_title}</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<h1>{_heading}</h1>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
10
main/templates/drop.html
Normal file
10
main/templates/drop.html
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>{_title}</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<h1>{_heading}</h1>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
25
main/templates/index.html
Normal file
25
main/templates/index.html
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>{_title}</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<h1>{_heading}</h1>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p>For select page click <a href="select">HERE</a></p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p>For delete page click <a href="delete">HERE</a></p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p>For insert page click <a href="insert">HERE</a></p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p>For create page click <a href="create">HERE</a></p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p>For drop page click <a href="drop">HERE</a></p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
10
main/templates/insert.html
Normal file
10
main/templates/insert.html
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>{_title}</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<h1>{_heading}</h1>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
10
main/templates/select.html
Normal file
10
main/templates/select.html
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>{_title}</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<h1>{_heading}</h1>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user