-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 55b588e
Showing
56 changed files
with
1,392 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using QRCoder; // Make sure you have this using directive | ||
using System; | ||
using System.Drawing; | ||
using System.IO; | ||
using static QRCoder.PayloadGenerator; | ||
using System.Reflection; | ||
using qrimage.Model; | ||
using System.Text; | ||
using Microsoft.AspNetCore.Hosting.Server; | ||
|
||
namespace qrimage.Controllers // Make sure this namespace matches your project namespace | ||
{ | ||
[Route("api/[controller]")] | ||
[ApiController] | ||
public class QRCodeController : ControllerBase | ||
{ | ||
[HttpPost] | ||
public IActionResult GenerateQRCode(QRCodeModel model) | ||
{ | ||
|
||
using (QRCodeGenerator qrGenerator = new QRCodeGenerator()) | ||
{ | ||
QRCodeData qrCodeData = qrGenerator.CreateQrCode(model.QRCodeText, QRCodeGenerator.ECCLevel.Q); | ||
BitmapByteQRCode qrCode = new(qrCodeData); | ||
string base64String = Convert.ToBase64String(qrCode.GetGraphic(20)); | ||
byte[] imageBytes = Convert.FromBase64String(base64String); | ||
string filePath = "QRCodeImage.png"; | ||
System.IO.File.WriteAllBytes(filePath, imageBytes); | ||
return Ok($"QR code image saved as: {filePath}"); | ||
} | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace qrimage.Controllers | ||
{ | ||
[ApiController] | ||
[Route("[controller]")] | ||
public class WeatherForecastController : ControllerBase | ||
{ | ||
private static readonly string[] Summaries = new[] | ||
{ | ||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" | ||
}; | ||
|
||
private readonly ILogger<WeatherForecastController> _logger; | ||
|
||
public WeatherForecastController(ILogger<WeatherForecastController> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
[HttpGet(Name = "GetWeatherForecast")] | ||
public IEnumerable<WeatherForecast> Get() | ||
{ | ||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast | ||
{ | ||
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), | ||
TemperatureC = Random.Shared.Next(-20, 55), | ||
Summary = Summaries[Random.Shared.Next(Summaries.Length)] | ||
}) | ||
.ToArray(); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace qrimage.Model | ||
{ | ||
public class QRCodeModel | ||
{ | ||
public string QRCodeText { get; set; } | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
var builder = WebApplication.CreateBuilder(args); | ||
|
||
// Add services to the container. | ||
|
||
builder.Services.AddControllers(); | ||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle | ||
builder.Services.AddEndpointsApiExplorer(); | ||
builder.Services.AddSwaggerGen(); | ||
|
||
var app = builder.Build(); | ||
|
||
// Configure the HTTP request pipeline. | ||
if (app.Environment.IsDevelopment()) | ||
{ | ||
app.UseSwagger(); | ||
app.UseSwaggerUI(); | ||
} | ||
|
||
app.UseHttpsRedirection(); | ||
|
||
app.UseAuthorization(); | ||
|
||
app.MapControllers(); | ||
|
||
app.Run(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/launchsettings.json", | ||
"iisSettings": { | ||
"windowsAuthentication": false, | ||
"anonymousAuthentication": true, | ||
"iisExpress": { | ||
"applicationUrl": "http://localhost:54829", | ||
"sslPort": 44365 | ||
} | ||
}, | ||
"profiles": { | ||
"http": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"launchUrl": "swagger", | ||
"applicationUrl": "http://localhost:5206", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"https": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"launchUrl": "swagger", | ||
"applicationUrl": "https://localhost:7030;http://localhost:5206", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"IIS Express": { | ||
"commandName": "IISExpress", | ||
"launchBrowser": true, | ||
"launchUrl": "swagger", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace qrimage | ||
{ | ||
public class WeatherForecast | ||
{ | ||
public DateOnly Date { get; set; } | ||
|
||
public int TemperatureC { get; set; } | ||
|
||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); | ||
|
||
public string? Summary { get; set; } | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
}, | ||
"AllowedHosts": "*" | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
}, | ||
"AllowedHosts": "*" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
{ | ||
"runtimeTarget": { | ||
"name": ".NETCoreApp,Version=v8.0", | ||
"signature": "" | ||
}, | ||
"compilationOptions": {}, | ||
"targets": { | ||
".NETCoreApp,Version=v8.0": { | ||
"qrimage/1.0.0": { | ||
"dependencies": { | ||
"QRCoder": "1.5.1", | ||
"Swashbuckle.AspNetCore": "6.4.0", | ||
"System.Drawing.Common": "8.0.5" | ||
}, | ||
"runtime": { | ||
"qrimage.dll": {} | ||
} | ||
}, | ||
"Microsoft.Extensions.ApiDescription.Server/6.0.5": {}, | ||
"Microsoft.OpenApi/1.2.3": { | ||
"runtime": { | ||
"lib/netstandard2.0/Microsoft.OpenApi.dll": { | ||
"assemblyVersion": "1.2.3.0", | ||
"fileVersion": "1.2.3.0" | ||
} | ||
} | ||
}, | ||
"Microsoft.Win32.SystemEvents/8.0.0": { | ||
"runtime": { | ||
"lib/net8.0/Microsoft.Win32.SystemEvents.dll": { | ||
"assemblyVersion": "8.0.0.0", | ||
"fileVersion": "8.0.23.53103" | ||
} | ||
}, | ||
"runtimeTargets": { | ||
"runtimes/win/lib/net8.0/Microsoft.Win32.SystemEvents.dll": { | ||
"rid": "win", | ||
"assetType": "runtime", | ||
"assemblyVersion": "8.0.0.0", | ||
"fileVersion": "8.0.23.53103" | ||
} | ||
} | ||
}, | ||
"QRCoder/1.5.1": { | ||
"runtime": { | ||
"lib/net6.0/QRCoder.dll": { | ||
"assemblyVersion": "1.5.1.0", | ||
"fileVersion": "1.5.1.0" | ||
} | ||
} | ||
}, | ||
"Swashbuckle.AspNetCore/6.4.0": { | ||
"dependencies": { | ||
"Microsoft.Extensions.ApiDescription.Server": "6.0.5", | ||
"Swashbuckle.AspNetCore.Swagger": "6.4.0", | ||
"Swashbuckle.AspNetCore.SwaggerGen": "6.4.0", | ||
"Swashbuckle.AspNetCore.SwaggerUI": "6.4.0" | ||
} | ||
}, | ||
"Swashbuckle.AspNetCore.Swagger/6.4.0": { | ||
"dependencies": { | ||
"Microsoft.OpenApi": "1.2.3" | ||
}, | ||
"runtime": { | ||
"lib/net6.0/Swashbuckle.AspNetCore.Swagger.dll": { | ||
"assemblyVersion": "6.4.0.0", | ||
"fileVersion": "6.4.0.0" | ||
} | ||
} | ||
}, | ||
"Swashbuckle.AspNetCore.SwaggerGen/6.4.0": { | ||
"dependencies": { | ||
"Swashbuckle.AspNetCore.Swagger": "6.4.0" | ||
}, | ||
"runtime": { | ||
"lib/net6.0/Swashbuckle.AspNetCore.SwaggerGen.dll": { | ||
"assemblyVersion": "6.4.0.0", | ||
"fileVersion": "6.4.0.0" | ||
} | ||
} | ||
}, | ||
"Swashbuckle.AspNetCore.SwaggerUI/6.4.0": { | ||
"runtime": { | ||
"lib/net6.0/Swashbuckle.AspNetCore.SwaggerUI.dll": { | ||
"assemblyVersion": "6.4.0.0", | ||
"fileVersion": "6.4.0.0" | ||
} | ||
} | ||
}, | ||
"System.Drawing.Common/8.0.5": { | ||
"dependencies": { | ||
"Microsoft.Win32.SystemEvents": "8.0.0" | ||
}, | ||
"runtime": { | ||
"lib/net8.0/System.Drawing.Common.dll": { | ||
"assemblyVersion": "8.0.0.0", | ||
"fileVersion": "8.0.524.21704" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"libraries": { | ||
"qrimage/1.0.0": { | ||
"type": "project", | ||
"serviceable": false, | ||
"sha512": "" | ||
}, | ||
"Microsoft.Extensions.ApiDescription.Server/6.0.5": { | ||
"type": "package", | ||
"serviceable": true, | ||
"sha512": "sha512-Ckb5EDBUNJdFWyajfXzUIMRkhf52fHZOQuuZg/oiu8y7zDCVwD0iHhew6MnThjHmevanpxL3f5ci2TtHQEN6bw==", | ||
"path": "microsoft.extensions.apidescription.server/6.0.5", | ||
"hashPath": "microsoft.extensions.apidescription.server.6.0.5.nupkg.sha512" | ||
}, | ||
"Microsoft.OpenApi/1.2.3": { | ||
"type": "package", | ||
"serviceable": true, | ||
"sha512": "sha512-Nug3rO+7Kl5/SBAadzSMAVgqDlfGjJZ0GenQrLywJ84XGKO0uRqkunz5Wyl0SDwcR71bAATXvSdbdzPrYRYKGw==", | ||
"path": "microsoft.openapi/1.2.3", | ||
"hashPath": "microsoft.openapi.1.2.3.nupkg.sha512" | ||
}, | ||
"Microsoft.Win32.SystemEvents/8.0.0": { | ||
"type": "package", | ||
"serviceable": true, | ||
"sha512": "sha512-9opKRyOKMCi2xJ7Bj7kxtZ1r9vbzosMvRrdEhVhDz8j8MoBGgB+WmC94yH839NPH+BclAjtQ/pyagvi/8gDLkw==", | ||
"path": "microsoft.win32.systemevents/8.0.0", | ||
"hashPath": "microsoft.win32.systemevents.8.0.0.nupkg.sha512" | ||
}, | ||
"QRCoder/1.5.1": { | ||
"type": "package", | ||
"serviceable": true, | ||
"sha512": "sha512-+v8VntytuDw4R1nCNJkSA7SWSizJoQfiByV1+nUjOwrDZEuaxefG73aKuuQjpaGtoZ7qlXpRbK70C23m1h3WLw==", | ||
"path": "qrcoder/1.5.1", | ||
"hashPath": "qrcoder.1.5.1.nupkg.sha512" | ||
}, | ||
"Swashbuckle.AspNetCore/6.4.0": { | ||
"type": "package", | ||
"serviceable": true, | ||
"sha512": "sha512-eUBr4TW0up6oKDA5Xwkul289uqSMgY0xGN4pnbOIBqCcN9VKGGaPvHX3vWaG/hvocfGDP+MGzMA0bBBKz2fkmQ==", | ||
"path": "swashbuckle.aspnetcore/6.4.0", | ||
"hashPath": "swashbuckle.aspnetcore.6.4.0.nupkg.sha512" | ||
}, | ||
"Swashbuckle.AspNetCore.Swagger/6.4.0": { | ||
"type": "package", | ||
"serviceable": true, | ||
"sha512": "sha512-nl4SBgGM+cmthUcpwO/w1lUjevdDHAqRvfUoe4Xp/Uvuzt9mzGUwyFCqa3ODBAcZYBiFoKvrYwz0rabslJvSmQ==", | ||
"path": "swashbuckle.aspnetcore.swagger/6.4.0", | ||
"hashPath": "swashbuckle.aspnetcore.swagger.6.4.0.nupkg.sha512" | ||
}, | ||
"Swashbuckle.AspNetCore.SwaggerGen/6.4.0": { | ||
"type": "package", | ||
"serviceable": true, | ||
"sha512": "sha512-lXhcUBVqKrPFAQF7e/ZeDfb5PMgE8n5t6L5B6/BQSpiwxgHzmBcx8Msu42zLYFTvR5PIqE9Q9lZvSQAcwCxJjw==", | ||
"path": "swashbuckle.aspnetcore.swaggergen/6.4.0", | ||
"hashPath": "swashbuckle.aspnetcore.swaggergen.6.4.0.nupkg.sha512" | ||
}, | ||
"Swashbuckle.AspNetCore.SwaggerUI/6.4.0": { | ||
"type": "package", | ||
"serviceable": true, | ||
"sha512": "sha512-1Hh3atb3pi8c+v7n4/3N80Jj8RvLOXgWxzix6w3OZhB7zBGRwsy7FWr4e3hwgPweSBpwfElqj4V4nkjYabH9nQ==", | ||
"path": "swashbuckle.aspnetcore.swaggerui/6.4.0", | ||
"hashPath": "swashbuckle.aspnetcore.swaggerui.6.4.0.nupkg.sha512" | ||
}, | ||
"System.Drawing.Common/8.0.5": { | ||
"type": "package", | ||
"serviceable": true, | ||
"sha512": "sha512-n55wb6rL8YG254AG+SfQOSQencrcnpKAAcYyEcvBuO2pob7ltXuZ5skBBdvLJOLVPKd1Ya8+8ColIM5AtBo5ww==", | ||
"path": "system.drawing.common/8.0.5", | ||
"hashPath": "system.drawing.common.8.0.5.nupkg.sha512" | ||
} | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"runtimeOptions": { | ||
"tfm": "net8.0", | ||
"frameworks": [ | ||
{ | ||
"name": "Microsoft.NETCore.App", | ||
"version": "8.0.0" | ||
}, | ||
{ | ||
"name": "Microsoft.AspNetCore.App", | ||
"version": "8.0.0" | ||
} | ||
], | ||
"configProperties": { | ||
"System.GC.Server": true, | ||
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false | ||
} | ||
} | ||
} |
Binary file added
BIN
+57.3 KB
bin/Debug/net8.0/runtimes/win/lib/net8.0/Microsoft.Win32.SystemEvents.dll
Binary file not shown.
4 changes: 4 additions & 0 deletions
4
obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// <autogenerated /> | ||
using System; | ||
using System.Reflection; | ||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")] |
Oops, something went wrong.