Application Server Controller of the Model View Controller
Contains the classes for the
While under construction, Schemas can be stored on the browser using Local Storage
A valid Schema will be generated. It can be validated on Google Developers Structured Data Testing Tool
The Controller class manages the flow of requests for Generating Schemas
Class method passed to the http demon
Here is where all GET and POST get treated
Here is where the Model is invoked
Here is where the View is invoked
Parameters: |
|
---|---|
Returns: | Requested page. |
Class method closes the http demon
Class containing the information of the current request
The information can be accessed through the get() method
Class method to obtain the key from the:
- QUERY_STRING: if it’s a GET request
- wsgi.input: if it’s a POST request
For security reasons, GET and POST methods cannot be used interchangeably.
Parameters: | key – |
---|---|
Returns: | value or empty string if key not found |
Class method to obtain all the keys
Returns: | all keys |
---|
Shuts down the http demon
Nothing more, nothing less
Must be an independent thread
The Application Server can be started directly from the command line
computer:~$ ./controller.py
or
computer:~$ python3 controller.py
A number of Application Servers can be started to serve at different ports.
computer:~$ ./controller.py 8001 &
or
computer:~$ python3 controller.py 8001 &
The server can be shut down from a browser.
http://localhost:port/quit
or using Python
from urllib.error import URLError
from urllib.request import urlopen
try:
urlopen('http://localhost:{0}/quit'.format(port))
except URLError:
pass
The server can be shut down from a browser.
http://localhost:port/restart
or using Python
from urllib.error import URLError
from urllib.request import urlopen
try:
urlopen('http://localhost:{0}/restart'.format(port))
except URLError:
pass