mirror of
https://github.com/yawaflua/yaflay.ru.git
synced 2025-12-13 17:16:26 +02:00
Some rework
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Hosting.StaticWebAssets;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Net;
|
||||
using System.Net.Http.Headers;
|
||||
@@ -29,14 +30,17 @@ namespace yaflay.ru.Новая_папка
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// GET: HomeController/Details/5
|
||||
[HttpGet("/{uri}")]
|
||||
[HttpGet("/r/{uri}")]
|
||||
public async Task<IActionResult> fromGitHub(string? uri)
|
||||
{
|
||||
if (uri == null) { return View("Index.cshtml"); }
|
||||
|
||||
if (uri == "Robots.txt") { return Ok("User-Agent: * \n Disallow: \"/*\""); }
|
||||
|
||||
string? url = await getUrlFromGit(uri);
|
||||
|
||||
return Redirect(url != null ? url : "https://yaflay.ru/");
|
||||
return Redirect(url != null ? url : uri);
|
||||
}
|
||||
|
||||
// GET: HomeController/Create
|
||||
|
||||
@@ -10,11 +10,13 @@ namespace yaflay.ru.Pages
|
||||
public IndexModel(ILogger<IndexModel> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
|
||||
}
|
||||
|
||||
public void OnGet()
|
||||
{
|
||||
Page();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
37
Program.cs
37
Program.cs
@@ -1,28 +1,17 @@
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddRazorPages();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using yaflay.ru;
|
||||
public class Program
|
||||
{
|
||||
app.UseExceptionHandler("/Error");
|
||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||
app.UseHsts();
|
||||
}
|
||||
app.UseRouting();
|
||||
app.UseHttpsRedirection();
|
||||
app.UseStaticFiles();
|
||||
app.UseEndpoints(endpoints =>
|
||||
public static void Main() => CreateHostBuilder()
|
||||
.Build()
|
||||
.Run();
|
||||
private static IHostBuilder CreateHostBuilder()
|
||||
{
|
||||
endpoints.MapControllers();
|
||||
return Host.CreateDefaultBuilder()
|
||||
.ConfigureWebHost(webHost => {
|
||||
webHost.UseStartup<Startup>();
|
||||
webHost.UseKestrel(kestrelOptions => { kestrelOptions.ListenAnyIP(80); });
|
||||
});
|
||||
app.UseRouting();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapRazorPages();
|
||||
|
||||
app.Run();
|
||||
}
|
||||
}
|
||||
49
Startup.cs
Normal file
49
Startup.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace yaflay.ru
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
private readonly IConfiguration configuration;
|
||||
public Startup()
|
||||
{
|
||||
configuration = new ConfigurationBuilder()
|
||||
.AddEnvironmentVariables(prefix: "m.")
|
||||
.AddJsonFile("appsettings.json", optional: true)
|
||||
.Build();
|
||||
}
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddControllers();
|
||||
services.AddRazorPages(k => { k.RootDirectory = "/Pages"; });
|
||||
services.AddControllersWithViews();
|
||||
services.AddDirectoryBrowser();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
// Add services to the container.
|
||||
// app.Services.AddRazorPages();
|
||||
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
|
||||
app.UseStaticFiles();
|
||||
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapRazorPages();
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user