Genie.serve
โ Functionserve(path::String = Genie.config.server_document_root, params...; kwparams...)
Serves a folder of static files located at path
. Allows Genie to be used as a static files web server. The params
and kwparams
arguments are forwarded to Genie.startup()
.
Arguments
path::String
: the folder of static files to be served by the serverparams
: additional arguments which are passed toGenie.startup
to control the web serverkwparams
: additional keyword arguments which are passed toGenie.startup
to control the web server
Examples
julia> Genie.serve("public", 8888, async = false, verbose = true)
[ Info: Ready!
2019-08-06 16:39:20:DEBUG:Main: Web Server starting at http://127.0.0.1:8888
[ Info: Listening on: 127.0.0.1:8888
[ Info: Accept (1): ๐ 0โ 0โ 1s 127.0.0.1:8888:8888 โฃ16
Genie.newapp
โ Functionnewapp(path::String = "."; autostart::Bool = true, fullstack::Bool = false, dbsupport::Bool = false, mvcsupport::Bool = false) :: Nothing
Scaffolds a new Genie app, setting up the file structure indicated by the various arguments.
Arguments
path::String
: the name of the app and the path where to bootstrap itautostart::Bool
: automatically start the app once the file structure is createdfullstack::Bool
: the type of app to be bootstrapped. The fullstack app includes MVC structure, DB connection code, and asset pipeline files.dbsupport::Bool
: bootstrap the files needed for DB connection setup via the SearchLight ORMmvcsupport::Bool
: adds the files used for HTML+Julia view templates rendering and working with resources
Examples
julia> Genie.newapp("MyGenieApp")
2019-08-06 16:54:15:INFO:Main: Done! New app created at MyGenieApp
2019-08-06 16:54:15:DEBUG:Main: Changing active directory to MyGenieApp
2019-08-06 16:54:15:DEBUG:Main: Installing app dependencies
Resolving package versions...
Updating `~/Dropbox/Projects/GenieTests/MyGenieApp/Project.toml`
[c43c736e] + Genie v0.10.1
Updating `~/Dropbox/Projects/GenieTests/MyGenieApp/Manifest.toml`
2019-08-06 16:54:27:INFO:Main: Starting your brand new Genie app - hang tight!
_____ _
| __|___ ___|_|___
| | | -_| | | -_|
|_____|___|_|_|_|___|
โ Info:
โ Starting Genie in >> DEV << mode
โ
[ Info: Logging to file at MyGenieApp/log/dev.log
[ Info: Ready!
2019-08-06 16:54:32:DEBUG:Main: Web Server starting at http://127.0.0.1:8000
2019-08-06 16:54:32:DEBUG:Main: Web Server running at http://127.0.0.1:8000
Genie.newapp_webservice
โ Functionnewapp_webservice(path::String = "."; autostart::Bool = true, dbsupport::Bool = false) :: Nothing
Template for scaffolding a new Genie app suitable for nimble web services.
Arguments
path::String
: the name of the app and the path where to bootstrap itautostart::Bool
: automatically start the app once the file structure is createddbsupport::Bool
: bootstrap the files needed for DB connection setup via the SearchLight ORM
Genie.newapp_mvc
โ Functionnewapp_mvc(path::String = "."; autostart::Bool = true) :: Nothing
Template for scaffolding a new Genie app suitable for MVC web applications (includes MVC structure and DB support).
Arguments
path::String
: the name of the app and the path where to bootstrap itautostart::Bool
: automatically start the app once the file structure is created
Genie.newapp_fullstack
โ Functionnewapp_fullstack(path::String = "."; autostart::Bool = true) :: Nothing
Template for scaffolding a new Genie app suitable for full stack web applications (includes MVC structure, DB support, and frontend asset pipeline).
Arguments
path::String
: the name of the app and the path where to bootstrap itautostart::Bool
: automatically start the app once the file structure is created
Genie.loadapp
โ Functionloadapp(path::String = "."; autostart::Bool = false) :: Nothing
Loads an existing Genie app from the file system, within the current Julia REPL session.
Arguments
path::String
: the path to the Genie app on the file system.autostart::Bool
: automatically start the app upon loading it.
Examples
shell> tree -L 1
.
โโโ Manifest.toml
โโโ Project.toml
โโโ bin
โโโ bootstrap.jl
โโโ config
โโโ env.jl
โโโ genie.jl
โโโ log
โโโ public
โโโ routes.jl
โโโ src
5 directories, 6 files
julia> using Genie
julia> Genie.loadapp(".")
_____ _
| __|___ ___|_|___
| | | -_| | | -_|
|_____|___|_|_|_|___|
โ Info:
โ Starting Genie in >> DEV << mode
โ
[ Info: Logging to file at MyGenieApp/log/dev.log
Genie.startup
โ Functionstartup(port::Int = Genie.config.server_port, host::String = Genie.config.server_host;
ws_port::Int = Genie.config.websockets_port, async::Bool = ! Genie.config.run_as_server) :: Nothing
Starts the web server. Alias for AppServer.startup
Arguments
port::Int
: the port used by the web serverhost::String
: the host used by the web serverws_port::Int
: the port used by the Web Sockets serverasync::Bool
: run the web server task asynchronously
Examples
julia> startup(8000, "127.0.0.1", async = false)
[ Info: Ready!
Web Server starting at http://127.0.0.1:8000
Genie.up
โ Functionstartup(port::Int = Genie.config.server_port, host::String = Genie.config.server_host;
ws_port::Int = Genie.config.websockets_port, async::Bool = ! Genie.config.run_as_server) :: ServersCollection
Starts the web server.
Arguments
port::Int
: the port used by the web serverhost::String
: the host used by the web serverws_port::Int
: the port used by the Web Sockets serverasync::Bool
: run the web server task asynchronously
Examples
julia> up(8000, "127.0.0.1", async = false)
[ Info: Ready!
Web Server starting at http://127.0.0.1:8000
Genie.down
โ Functiondown(; webserver::Bool = true, websockets::Bool = true) :: ServersCollection
Shuts down the servers optionally indicating which of the webserver
and websockets
servers to be stopped.
Genie.run
โ Functionrun() :: Nothing
Runs the Genie app by parsing the command line args and invoking the corresponding actions. Used internally to parse command line arguments.
Genie.newcontroller
โ Functionnewcontroller(controller_name::Union{String,Symbol}) :: Nothing
Creates a new controller
file. If pluralize
is false
, the name of the controller is not automatically pluralized.
Genie.newresource
โ Functionnewresource(resource_name::Union{String,Symbol}; pluralize::Bool = true, context::Union{Module,Nothing} = nothing) :: Nothing
Creates all the files associated with a new resource. If pluralize
is false
, the name of the resource is not automatically pluralized.
Genie.newtask
โ Functionnewtask(task_name::Union{String,Symbol}) :: Nothing
Creates a new Genie Task
file.
Genie.load_libs
โ Functionload_libs(root_dir::String = Genie.config.path_lib) :: Nothing
Recursively adds subfolders of lib/
to LOAD_PATH. The lib/
folder, if present, is designed to host user code in the form of .jl files. This function loads user code into the Genie app.
Genie.load_resources
โ Functionload_resources(root_dir::String = Genie.config.path_resources) :: Nothing
Recursively adds subfolders of resources/
to LOAD_PATH.
Genie.load_helpers
โ Functionload_helpers(root_dir::String = Genie.config.path_helpers) :: Nothing
Recursively adds subfolders of helpers/
to LOAD_PATH.
Genie.load_configurations
โ Functionload_configurations(root_dir::String = Genie.config.path_config; context::Union{Module,Nothing} = nothing) :: Nothing
Loads (includes) the framework's configuration files into the app's module context
. The files are set up with Revise
to be automatically reloaded.
Genie.load_initializers
โ Functionload_initializers(root_dir::String = Genie.config.path_config; context::Union{Module,Nothing} = nothing) :: Nothing
Loads (includes) the framework's initializers. The files are set up with Revise
to be automatically reloaded.
Genie.load_plugins
โ Functionload_plugins(root_dir::String = Genie.config.path_plugins; context::Union{Module,Nothing} = nothing) :: Nothing
Loads (includes) the framework's plugins initializers.
Genie.load_routes_definitions
โ Functionload_routes_definitions(routes_file::String = Genie.ROUTES_FILE_NAME; context::Union{Module,Nothing} = nothing) :: Nothing
Loads the routes file.
Genie.secret_token
โ Functionsecret_token(generate_if_missing=true) :: String
Return the secret token used in the app for encryption and salting.
Usually, this token is defined through Genie.secret_token!
in the config/secrets.jl
file. Here, a temporary one is generated for the current session if no other token is defined and generate_if_missing
is true.
Genie.default_context
โ Functiondefault_context(context::Union{Module,Nothing})
Sets the module in which the code is loaded (the app's module)
Genie.load
โ Functionload(; context::Union{Module,Nothing} = nothing) :: Nothing
Main entry point to loading a Genie app.
Genie.replprint
โ Functionreplprint(output::String, terminal;
newline::Int = 0, clearline::Int = 1, color::Symbol = :white, bold::Bool = false, sleep_time::Float64 = 0.2,
prefix::String = "", prefix_color::Symbol = :green, prefix_bold::Bool = true)
Prints app loading progress to the console.