Program.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Threading.Tasks;
  6. using Microsoft.AspNetCore.Builder;
  7. using Microsoft.AspNetCore.Hosting;
  8. using Microsoft.AspNetCore.Http;
  9. using Microsoft.AspNetCore.StaticFiles;
  10. using Microsoft.Extensions.DependencyInjection;
  11. using Microsoft.Extensions.FileProviders;
  12. using Microsoft.Extensions.Logging;
  13. namespace TestTestTest
  14. {
  15. public class Startup
  16. {
  17. // This method gets called by the runtime. Use this method to add services to the container.
  18. // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
  19. public void ConfigureServices(IServiceCollection services)
  20. {
  21. }
  22. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  23. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
  24. {
  25. loggerFactory.AddConsole();
  26. if (env.IsDevelopment())
  27. {
  28. app.UseDeveloperExceptionPage();
  29. }
  30. var path = Path.Combine(env.ContentRootPath);
  31. var provider = new PhysicalFileProvider(path);
  32. provider.Watch("*.*");
  33. // Set up custom content types -associating file extension to MIME type
  34. var contentTypeProvider = new FileExtensionContentTypeProvider();
  35. // Add new mappings
  36. contentTypeProvider.Mappings[".hdr"] = "application/octet-stream";
  37. contentTypeProvider.Mappings[".babylon"] = "application/json";
  38. contentTypeProvider.Mappings[".fx"] = "text/plain";
  39. contentTypeProvider.Mappings[".map"] = "text/plain";
  40. var options = new StaticFileOptions();
  41. options.RequestPath = "";
  42. options.FileProvider = provider;
  43. options.ContentTypeProvider = contentTypeProvider;
  44. app.UseStaticFiles(options);
  45. }
  46. }
  47. public class Program
  48. {
  49. public static void Main(string[] args)
  50. {
  51. // PG
  52. var currentDirectory = Directory.GetCurrentDirectory();
  53. // BJS
  54. var babylonjsDirectory = new DirectoryInfo(currentDirectory).Parent.FullName;
  55. var host = new WebHostBuilder()
  56. .UseKestrel()
  57. .UseContentRoot(babylonjsDirectory)
  58. .UseIISIntegration()
  59. .UseStartup<Startup>()
  60. .Build();
  61. host.Run();
  62. }
  63. }
  64. }