Skip to content

Instantly share code, notes, and snippets.

@joseph-montanez
Created February 20, 2011 20:42
Show Gist options
  • Save joseph-montanez/836289 to your computer and use it in GitHub Desktop.
Save joseph-montanez/836289 to your computer and use it in GitHub Desktop.
Set_Tag_Separators (Start_With => "[[", Stop_With => "]]"); crashes!
@@IF@@ [[dberror]] = "Login Failed"
Access to the database is not permitted
@@ELSIF@@ [[dberror]] = "Driver Failed"
Database driver failed
@@END_IF@@
<P>Hello [[NAME]]
ddd
dfd
[[EMAIL]] <br />
testing
with AWS.Response;
with Templates_Parser;
with Ada.Strings.Unbounded;
use Templates_Parser;
package body Index is
function Get (Request : AWS.Status.Data) return AWS.Response.Data is
pragma Unreferenced (Request);
package Unbounded renames Ada.Strings.Unbounded;
use type Vector_Tag;
Translations : Translate_Set;
File : String := "demo.tmplt";
begin
Set_Tag_Separators (Start_With => "[[", Stop_With => "]]");
Insert (Translations, Assoc ("dberror", ""));
Insert (Translations, Assoc ("page_title", "Account Login"));
declare
Source : String := Parse (
Filename => File,
Translations => Translations,
Cached => True
);
begin
return AWS.Response.Build ("text/html", Source);
end;
end Get;
end Index;
with AWS.Response;
with AWS.Status;
package Index is
function Get (Request : AWS.Status.Data) return AWS.Response.Data;
end Index;
with Ada.Text_IO;
with AWS.Default;
with AWS.Server;
with AWS.Config;
with AWS.Config.Set;
with AWS.Services.Dispatchers.URI;
with AWS.Services.Page_Server;
-- Pages
with Index;
procedure Server is
HTTP : AWS.Server.HTTP;
Conf : AWS.Config.Object := AWS.Config.Get_Current;
Root : AWS.Services.Dispatchers.URI.Handler;
begin
-- Server Configuration, this could be in an INI file
AWS.Config.Set.Server_Port (Conf, 8184);
AWS.Config.Set.Max_Connection (Conf, 1024);
--
AWS.Services.Dispatchers.URI.Register (Root, "/", Index.Get'Access);
AWS.Server.Start (HTTP, Root, Conf);
Ada.Text_IO.Put_Line (
"Running on on port"
& Positive'Image (AWS.Config.Server_Port (Conf))
& ", Q to stop"
);
AWS.Server.Wait (AWS.Server.Q_Key_Pressed);
AWS.Server.Shutdown (HTTP);
end Server;
with "aws";
project Server is
for Source_Dirs use (".");
for Main use ("server.adb");
for Object_Dir use ".";
for Exec_Dir use ".";
package Builder is
for Default_Switches ("ada") use ("-gnat05", "-gnaty", "-gnatv", "-gnato", "-g");
end Builder;
package Binder is
for Default_Switches ("ada") use ("-r", "-E");
end Binder;
package Check is
for Default_Switches ("ada") use ("-d");
end Check;
end Server;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment