Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Commit

Permalink
Merge pull request #2099 from NancyFx/revert-2097-delete-self-host
Browse files Browse the repository at this point in the history
Revert "Delete Hosting.Self projects. "
  • Loading branch information
grumpydev committed Nov 1, 2015
2 parents bba7288 + b910027 commit 1b64f7a
Show file tree
Hide file tree
Showing 26 changed files with 2,203 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Nancy.Demo.Hosting.Self/Models/Index.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace Nancy.Demo.Hosting.Self.Models
{
public class Index
{
public string Name { get; set; }

public string Posted { get; set; }

public Index()
{
this.Posted = "Nothing :-(";
}
}
}
177 changes: 177 additions & 0 deletions src/Nancy.Demo.Hosting.Self/Nancy.Demo.Hosting.Self.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{0B3EA40E-F7D8-4E14-A30F-1536F41B62D1}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Nancy.Demo.Hosting.Self</RootNamespace>
<AssemblyName>Nancy.Demo.Hosting.Self</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<StartupObject>Nancy.Demo.Hosting.Self.Program</StartupObject>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'MonoDebug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\MonoDebug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<CodeAnalysisLogFile>bin\Debug\Nancy.Demo.Hosting.Self.exe.CodeAnalysisLog.xml</CodeAnalysisLogFile>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
<WarningLevel>4</WarningLevel>
<Optimize>false</Optimize>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'MonoRelease|x86'">
<OutputPath>bin\x86\MonoRelease\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<CodeAnalysisLogFile>bin\Release\Nancy.Demo.Hosting.Self.exe.CodeAnalysisLog.xml</CodeAnalysisLogFile>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System">
</Reference>
<Reference Include="System.Core">
</Reference>
<Reference Include="System.Xml.Linq">
</Reference>
<Reference Include="System.Data.DataSetExtensions">
</Reference>
<Reference Include="Microsoft.CSharp">
</Reference>
<Reference Include="System.Data">
</Reference>
<Reference Include="System.Xml">
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Models\Index.cs" />
<Compile Include="Program.cs" />
<Compile Include="TestModule.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Nancy.Hosting.Self\Nancy.Hosting.Self.csproj">
<Project>{AA7F66EB-EC2C-47DE-855F-30B3E6EF2134}</Project>
<Name>Nancy.Hosting.Self</Name>
</ProjectReference>
<ProjectReference Include="..\Nancy.ViewEngines.Spark\Nancy.ViewEngines.Spark.csproj">
<Project>{4b7e35df-1569-4346-b180-a09615723095}</Project>
<Name>Nancy.ViewEngines.Spark</Name>
</ProjectReference>
<ProjectReference Include="..\Nancy\Nancy.csproj">
<Project>{34576216-0DCA-4B0F-A0DC-9075E75A676F}</Project>
<Name>Nancy</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config">
<SubType>Designer</SubType>
</None>
<Content Include="Views\FileUpload.spark">
<SubType>Designer</SubType>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="Views\staticview.html">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
30 changes: 30 additions & 0 deletions src/Nancy.Demo.Hosting.Self/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
namespace Nancy.Demo.Hosting.Self
{
using System;
using System.Diagnostics;

using Nancy.Hosting.Self;

class Program
{
static void Main()
{
using (var nancyHost = new NancyHost(new Uri("http://localhost:8888/nancy/"), new Uri("http://127.0.0.1:8898/nancy/"), new Uri("http://localhost:8889/nancytoo/")))
{
nancyHost.Start();

Console.WriteLine("Nancy now listening - navigating to http://localhost:8888/nancy/. Press enter to stop");
try
{
Process.Start("http://localhost:8888/nancy/");
}
catch (Exception)
{
}
Console.ReadKey();
}

Console.WriteLine("Stopped. Good bye!");
}
}
}
1 change: 1 addition & 0 deletions src/Nancy.Demo.Hosting.Self/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

45 changes: 45 additions & 0 deletions src/Nancy.Demo.Hosting.Self/TestModule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
namespace Nancy.Demo.Hosting.Self
{
using System.Linq;

using Nancy.Demo.Hosting.Self.Models;

public class TestModule : NancyModule
{
public TestModule()
{
Get["/"] = parameters => {
return View["staticview", this.Request.Url];
};

Get["/testing"] = parameters =>
{
return View["staticview", this.Request.Url];
};

Get["/fileupload"] = x =>
{
var model = new Index() { Name = "Boss Hawg" };

return View["FileUpload", model];
};

Post["/fileupload"] = x =>
{
var model = new Index() { Name = "Boss Hawg" };

var file = this.Request.Files.FirstOrDefault();
string fileDetails = "None";

if (file != null)
{
fileDetails = string.Format("{3} - {0} ({1}) {2}bytes", file.Name, file.ContentType, file.Value.Length, file.Key);
}

model.Posted = fileDetails;

return View["FileUpload", model];
};
}
}
}
17 changes: 17 additions & 0 deletions src/Nancy.Demo.Hosting.Self/Views/FileUpload.spark
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<viewdata model="Nancy.Demo.Hosting.Self.Models.Index" />
<html>
<head>
<title>Nancy Self Host Demo</title>
</head>
<body>
<h1>Hello ${Model.Name}!</h1>
<p>This is a Spark view rendered via the self hosting.</p>
<p>You uploaded: ${Model.Posted}</p>
<p>
<form action="~/fileupload" method="POST" enctype="multipart/form-data">
<input name="upload" type="file" size="40"/>
<input type="submit" value="Post!"/>
</form>
</p>
</body>
</html>
25 changes: 25 additions & 0 deletions src/Nancy.Demo.Hosting.Self/Views/staticview.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Nancy - Static view served by self-host</title>
</head>
<body>
<h1>Static view served by self-host</h1>
<p>
This view was served by the Nancy self-host.
</p>
<ul>
<li>Scheme: @Model.Scheme</li>
<li>HostName: @Model.HostName</li>
<li>Port: @Model.Port</li>
<li>BasePath: @Model.BasePath</li>
<li>Path: @Model.Path</li>
</ul>
<a href="http://localhost:8888/nancy/">http://localhost:8888/nancy/</a><br/>
<a href="http://localhost:8888/nancy/testing">http://localhost:8888/nancy/testing</a><br/>
<a href="http://127.0.0.1:8898/nancy/">http://127.0.0.1:8898/nancy/</a><br/>
<a href="http://127.0.0.1:8898/nancy/testing">http://127.0.0.1:8898/nancy/testing</a><br/>
<a href="http://localhost:8889/nancytoo/">http://localhost:8889/nancytoo/</a><br/>
<a href="http://localhost:8889/nancytoo/testing">http://localhost:8889/nancytoo/testing</a><br/>
</body>
</html>
7 changes: 7 additions & 0 deletions src/Nancy.Demo.Hosting.Self/app.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0"?>

<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
</configuration>
Loading

0 comments on commit 1b64f7a

Please sign in to comment.