_____/\\\\\\\\\\\___________________________________________________________________________________________/\\\\\_____________________________________________________________________________________________________________________________
___/\\\/////////\\\_______________________________________________________________________________________/\\\///\\\___________________________________________________________________________________________________________________________
__\//\\\______\///______________________________________________________________________________________/\\\/__\///\\\____/\\\\\\\\\__________________________________________________/\\\_______/\\\__________________________________________
___\////\\\_____________/\\\\\\\\______/\\\\\\\\__/\\\____/\\\__/\\/\\\\\\\______/\\\\\\\\_____________/\\\______\//\\\__/\\\/////\\\_____/\\\\\\\\___/\\/\\\\\\\___/\\\\\\\\\_____/\\\\\\\\\\\_\///______/\\\\\_____/\\/\\\\\\____/\\\\\\\\\\_
______\////\\\________/\\\/////\\\___/\\\//////__\/\\\___\/\\\_\/\\\/////\\\___/\\\/////\\\___________\/\\\_______\/\\\_\/\\\\\\\\\\____/\\\/////\\\_\/\\\/////\\\_\////////\\\___\////\\\////___/\\\___/\\\///\\\__\/\\\////\\\__\/\\\//////__
_________\////\\\____/\\\\\\\\\\\___/\\\_________\/\\\___\/\\\_\/\\\___\///___/\\\\\\\\\\\____________\//\\\______/\\\__\/\\\//////____/\\\\\\\\\\\__\/\\\___\///____/\\\\\\\\\\_____\/\\\______\/\\\__/\\\__\//\\\_\/\\\__\//\\\_\/\\\\\\\\\\_
__/\\\______\//\\\__\//\\///////___\//\\\________\/\\\___\/\\\_\/\\\_________\//\\///////______________\///\\\__/\\\____\/\\\_________\//\\///////___\/\\\__________/\\\/////\\\_____\/\\\_/\\__\/\\\_\//\\\__/\\\__\/\\\___\/\\\_\////////\\\_
_\///\\\\\\\\\\\/____\//\\\\\\\\\\__\///\\\\\\\\_\//\\\\\\\\\__\/\\\__________\//\\\\\\\\\\______________\///\\\\\/_____\/\\\__________\//\\\\\\\\\\_\/\\\_________\//\\\\\\\\/\\____\//\\\\\___\/\\\__\///\\\\\/___\/\\\___\/\\\__/\\\\\\\\\\_
___\///////////_______\//////////_____\////////___\/////////___\///____________\//////////_________________\/////_______\///____________\//////////__\///___________\////////\//______\/////____\///_____\/////_____\///____\///__\//////////__
This is a base for intense routing applications. Use this in your projects that need a strong, well written, secure and simple HTTP server with a optional debugger. This has a very weird setup as well but it is still handy.
-
Make sure crystal is installed
-
Make sure the following is installed
sudo apt-get install gcc pkg-config git tzdata \ libpcre3-dev libevent-dev libyaml-dev \ libgmp-dev libssl-dev libxml2-dev
-
Make sure you include the crystal file and start routing
Take the SRC directory and Settings directory and place it into the desired project location. Then create your main crystal file or embed the crystal functions near or around that current set directory. An example is the following tree
├── example_File_Input
│ └── example.html
├── router.cr
├── Settings
│ ├── Router.json
│ └── Server.json
└── src
├── Server.cr
├── Server_Debug.cr
├── Server_FINF.cr
├── Server_Json.cr
├── Server_Responder.cr
├── Server_Router.cr
└── Template.cr
where router.cr in other terms main.cr
would look like this
#
# ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
# :
# :
# :
# : _____/\\\\\\\\\\\___________________________________________________________________________/\\\\\\\\\\\_________________________________________________________________________________________________________/\\\\\\\\\\\\_________________________________________________/\\\\\\_______________________________________________________________________________________________
# : ___/\\\/////////\\\_______________________________________________________________________/\\\/////////\\\______________________________________________________________________________________________________\/\\\////////\\\______________________________________________\////\\\_______________________________________________________________________________________________
# : __\//\\\______\///_______________________________________________________________________\//\\\______\///____________________________________________________________/\\\_____/\\\_________/\\\__/\\\___________\/\\\______\//\\\________________________________________________\/\\\____________________/\\\\\\\\\_______________________________________________________/\\\______
# : ___\////\\\_____________/\\\\\\\\__/\\\\\\\\\_____/\\/\\\\\\\______/\\\\\\\\______________\////\\\_____________/\\\\\\\\______/\\\\\\\\__/\\\____/\\\__/\\/\\\\\\\__\///___/\\\\\\\\\\\___\//\\\/\\\____________\/\\\_______\/\\\_____/\\\\\\\\___/\\\____/\\\_____/\\\\\\\\_____\/\\\________/\\\\\_____/\\\/////\\\____/\\\\\__/\\\\\_______/\\\\\\\\___/\\/\\\\\\____/\\\\\\\\\\\_
# : ______\////\\\________/\\\//////__\////////\\\___\/\\\/////\\\___/\\\/////\\\________________\////\\\________/\\\/////\\\___/\\\//////__\/\\\___\/\\\_\/\\\/////\\\__/\\\_\////\\\////_____\//\\\\\_____________\/\\\_______\/\\\___/\\\/////\\\_\//\\\__/\\\____/\\\/////\\\____\/\\\______/\\\///\\\__\/\\\\\\\\\\___/\\\///\\\\\///\\\___/\\\/////\\\_\/\\\////\\\__\////\\\////__
# : _________\////\\\____/\\\___________/\\\\\\\\\\__\/\\\___\///___/\\\\\\\\\\\____________________\////\\\____/\\\\\\\\\\\___/\\\_________\/\\\___\/\\\_\/\\\___\///__\/\\\____\/\\\__________\//\\\______________\/\\\_______\/\\\__/\\\\\\\\\\\___\//\\\/\\\____/\\\\\\\\\\\_____\/\\\_____/\\\__\//\\\_\/\\\//////___\/\\\_\//\\\__\/\\\__/\\\\\\\\\\\__\/\\\__\//\\\____\/\\\______
# : __/\\\______\//\\\__\//\\\_________/\\\/////\\\__\/\\\_________\//\\///////______________/\\\______\//\\\__\//\\///////___\//\\\________\/\\\___\/\\\_\/\\\_________\/\\\____\/\\\_/\\___/\\_/\\\_______________\/\\\_______/\\\__\//\\///////_____\//\\\\\____\//\\///////______\/\\\____\//\\\__/\\\__\/\\\_________\/\\\__\/\\\__\/\\\_\//\\///////___\/\\\___\/\\\____\/\\\_/\\__
# : _\///\\\\\\\\\\\/____\///\\\\\\\\_\//\\\\\\\\/\\_\/\\\__________\//\\\\\\\\\\___________\///\\\\\\\\\\\/____\//\\\\\\\\\\__\///\\\\\\\\_\//\\\\\\\\\__\/\\\_________\/\\\____\//\\\\\___\//\\\\/________________\/\\\\\\\\\\\\/____\//\\\\\\\\\\____\//\\\______\//\\\\\\\\\\__/\\\\\\\\\__\///\\\\\/___\/\\\_________\/\\\__\/\\\__\/\\\__\//\\\\\\\\\\_\/\\\___\/\\\____\//\\\\\___
# : ___\///////////________\////////___\////////\//__\///____________\//////////______________\///////////_______\//////////_____\////////___\/////////___\///__________\///______\/////_____\////__________________\////////////_______\//////////______\///________\//////////__\/////////_____\/////_____\///__________\///___\///___\///____\//////////__\///____\///______\/////____
# :
# : This code belongs to the scare security organization. This code you may use and may re distribute as this is a open source project as a base for modern day applications which need simple local HTTP routing
# :
# : Please make sure before distributing code is not directly pasted and this code is taken into affect, modified, remade, re named, re created, re modified and other forms of manipulation are required
# :
# : If you do not modify make sure to give credits to the contributors and the security organization that developed this code
# :
# : https://github.com/Scare-Security/Safe-And-Secure-Router
# :
# :...............................................................................................................................................................................................................................................................................................................................................................................................................................................................................
require "./src/Server_Router.cr"
def main
application = Server::Base.new
application_settings = JParse::J.new
application.process "/" do "" end
application.run(application_settings.preproc, true)
end
# call main
main
make sure that before making the move
application.process "/" do "" end
you make sure to go into the src/Server_Responder.cr
crystal source code file and modify what the server is allowed to use. This is declared here
#
# ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
# :
# :
# :
# : _____/\\\\\\\\\\\___________________________________________________________________________/\\\\\\\\\\\_________________________________________________________________________________________________________/\\\\\\\\\\\\_________________________________________________/\\\\\\_______________________________________________________________________________________________
# : ___/\\\/////////\\\_______________________________________________________________________/\\\/////////\\\______________________________________________________________________________________________________\/\\\////////\\\______________________________________________\////\\\_______________________________________________________________________________________________
# : __\//\\\______\///_______________________________________________________________________\//\\\______\///____________________________________________________________/\\\_____/\\\_________/\\\__/\\\___________\/\\\______\//\\\________________________________________________\/\\\____________________/\\\\\\\\\_______________________________________________________/\\\______
# : ___\////\\\_____________/\\\\\\\\__/\\\\\\\\\_____/\\/\\\\\\\______/\\\\\\\\______________\////\\\_____________/\\\\\\\\______/\\\\\\\\__/\\\____/\\\__/\\/\\\\\\\__\///___/\\\\\\\\\\\___\//\\\/\\\____________\/\\\_______\/\\\_____/\\\\\\\\___/\\\____/\\\_____/\\\\\\\\_____\/\\\________/\\\\\_____/\\\/////\\\____/\\\\\__/\\\\\_______/\\\\\\\\___/\\/\\\\\\____/\\\\\\\\\\\_
# : ______\////\\\________/\\\//////__\////////\\\___\/\\\/////\\\___/\\\/////\\\________________\////\\\________/\\\/////\\\___/\\\//////__\/\\\___\/\\\_\/\\\/////\\\__/\\\_\////\\\////_____\//\\\\\_____________\/\\\_______\/\\\___/\\\/////\\\_\//\\\__/\\\____/\\\/////\\\____\/\\\______/\\\///\\\__\/\\\\\\\\\\___/\\\///\\\\\///\\\___/\\\/////\\\_\/\\\////\\\__\////\\\////__
# : _________\////\\\____/\\\___________/\\\\\\\\\\__\/\\\___\///___/\\\\\\\\\\\____________________\////\\\____/\\\\\\\\\\\___/\\\_________\/\\\___\/\\\_\/\\\___\///__\/\\\____\/\\\__________\//\\\______________\/\\\_______\/\\\__/\\\\\\\\\\\___\//\\\/\\\____/\\\\\\\\\\\_____\/\\\_____/\\\__\//\\\_\/\\\//////___\/\\\_\//\\\__\/\\\__/\\\\\\\\\\\__\/\\\__\//\\\____\/\\\______
# : __/\\\______\//\\\__\//\\\_________/\\\/////\\\__\/\\\_________\//\\///////______________/\\\______\//\\\__\//\\///////___\//\\\________\/\\\___\/\\\_\/\\\_________\/\\\____\/\\\_/\\___/\\_/\\\_______________\/\\\_______/\\\__\//\\///////_____\//\\\\\____\//\\///////______\/\\\____\//\\\__/\\\__\/\\\_________\/\\\__\/\\\__\/\\\_\//\\///////___\/\\\___\/\\\____\/\\\_/\\__
# : _\///\\\\\\\\\\\/____\///\\\\\\\\_\//\\\\\\\\/\\_\/\\\__________\//\\\\\\\\\\___________\///\\\\\\\\\\\/____\//\\\\\\\\\\__\///\\\\\\\\_\//\\\\\\\\\__\/\\\_________\/\\\____\//\\\\\___\//\\\\/________________\/\\\\\\\\\\\\/____\//\\\\\\\\\\____\//\\\______\//\\\\\\\\\\__/\\\\\\\\\__\///\\\\\/___\/\\\_________\/\\\__\/\\\__\/\\\__\//\\\\\\\\\\_\/\\\___\/\\\____\//\\\\\___
# : ___\///////////________\////////___\////////\//__\///____________\//////////______________\///////////_______\//////////_____\////////___\/////////___\///__________\///______\/////_____\////__________________\////////////_______\//////////______\///________\//////////__\/////////_____\/////_____\///__________\///___\///___\///____\//////////__\///____\///______\/////____
# :
# : This code belongs to the scare security organization. This code you may use and may re distribute as this is a open source project as a base for modern day applications which need simple local HTTP routing
# :
# : Please make sure before distributing code is not directly pasted and this code is taken into affect, modified, remade, re named, re created, re modified and other forms of manipulation are required
# :
# : If you do not modify make sure to give credits to the contributors and the security organization that developed this code
# :
# : https://github.com/Scare-Security/Safe-And-Secure-Router
# :
# :...............................................................................................................................................................................................................................................................................................................................................................................................................................................................................
require "./Template.cr"
module Responder
class Switcher
def return_base_path(path_of_file : String)
server_Locations = {
"/" => "main.html",
}
server_Locations[path_of_file]
end
end
end
the list server_Locations
tells the server what file is allowed and what filepath the user can access via post or get request. Make sure you define the request path to get to that folder. For example if you make a request to /
the server knows to load the main.html
file that is inside of the path and list. Make sure to also make no controversal names or filepaths. if two are the same either the debugger will output massive logs or crystal will error out.
-
Pre generation: If the file
main.html
is not in the same directory, deleted or is not found the server will re generate a new one, once you reload the server it will be loaded as a file. -
Debugger: The server has standard debugger on it, where when a persons or robot makes a request to the server the debugger will log the filepath, the request and response headers, the response codes and even file information of the requested file. If you use this in production make sure you build an IDS to check and verify the file or to check for a very specific file.