Last active
August 13, 2022 15:35
-
-
Save LeftofZen/6e1c9a09dac51ae7141b2ec6d04afec3 to your computer and use it in GitHub Desktop.
A simple file server in asp.net 6 that servers openloco obj files in base64 encoding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var builder = WebApplication.CreateBuilder(args); | |
// Add services to the container. | |
builder.Services.AddEndpointsApiExplorer(); | |
builder.Services.AddSwaggerGen(); | |
var app = builder.Build(); | |
// Configure the HTTP request pipeline. | |
if (app.Environment.IsDevelopment()) | |
{ | |
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle | |
app.UseSwagger(); | |
app.UseSwaggerUI(); | |
} | |
app.MapGet("/object/{obj}", (string obj) => | |
{ | |
const string objFolderPath = @"Q:\Games\Locomotion\Objects"; | |
var objFilename = Path.Combine(objFolderPath, $"{obj}.dat"); | |
if (File.Exists(objFilename)) | |
{ | |
var bytes = File.ReadAllBytes(objFilename); | |
return System.Convert.ToBase64String(bytes); | |
} | |
return null; | |
}); | |
app.Run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment