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 Microsoft.AspNetCore.Mvc;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
@@ -29,14 +30,17 @@ namespace yaflay.ru.Новая_папка
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET: HomeController/Details/5
|
// GET: HomeController/Details/5
|
||||||
[HttpGet("/{uri}")]
|
[HttpGet("/r/{uri}")]
|
||||||
public async Task<IActionResult> fromGitHub(string? 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);
|
string? url = await getUrlFromGit(uri);
|
||||||
|
|
||||||
return Redirect(url != null ? url : "https://yaflay.ru/");
|
return Redirect(url != null ? url : uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET: HomeController/Create
|
// GET: HomeController/Create
|
||||||
|
|||||||
@@ -10,11 +10,13 @@ namespace yaflay.ru.Pages
|
|||||||
public IndexModel(ILogger<IndexModel> logger)
|
public IndexModel(ILogger<IndexModel> logger)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnGet()
|
public void OnGet()
|
||||||
{
|
{
|
||||||
|
Page();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
41
Program.cs
41
Program.cs
@@ -1,28 +1,17 @@
|
|||||||
var builder = WebApplication.CreateBuilder(args);
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using yaflay.ru;
|
||||||
// Add services to the container.
|
public class Program
|
||||||
builder.Services.AddRazorPages();
|
|
||||||
|
|
||||||
var app = builder.Build();
|
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
|
||||||
if (!app.Environment.IsDevelopment())
|
|
||||||
{
|
{
|
||||||
app.UseExceptionHandler("/Error");
|
public static void Main() => CreateHostBuilder()
|
||||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
.Build()
|
||||||
app.UseHsts();
|
.Run();
|
||||||
}
|
private static IHostBuilder CreateHostBuilder()
|
||||||
app.UseRouting();
|
{
|
||||||
app.UseHttpsRedirection();
|
return Host.CreateDefaultBuilder()
|
||||||
app.UseStaticFiles();
|
.ConfigureWebHost(webHost => {
|
||||||
app.UseEndpoints(endpoints =>
|
webHost.UseStartup<Startup>();
|
||||||
{
|
webHost.UseKestrel(kestrelOptions => { kestrelOptions.ListenAnyIP(80); });
|
||||||
endpoints.MapControllers();
|
});
|
||||||
});
|
|
||||||
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