Skip to content

QRCodeGen is the final project for the Code Louisville May 2022 Software Developer course 1 cohort. It is an Azure Function that runs locally and has been tested on a machine installed with Windows (64-bit) using Visual Studio Code.

Notifications You must be signed in to change notification settings

ajhughesdev/QRCodeGen

Repository files navigation

QR Code Generator

QRCodeGen is the final project for the Code Louisville May 2022 Software Developer course 1 cohort. It is an Azure Function that runs locally and has been tested on a machine installed with Windows (64-bit) using Visual Studio Code. Please note, this project represents a change from the project plan previously submitted.

Install Dependencies

Use the latest releases of these tools. You can check your current versions by running:

func --version
dotnet --version
az version

Clone Repo and Run the Function

Clone the repo and move into the project folder:

git clone https://github.com/ajhughesdev/QRCodeGen
cd QRCodeGen

To start the generator, use the Azure CLI command:

func start

If the above command fails, tell the program what language to expect by adding a --csharp flag.

func start --csharp

When executing the command for the first time, it may take a few moments to load so please be patient. Following a successful build, you should see a version of the following:

Azure Functions Core Tools
Core Tools Version:       4.0.4653 Commit hash: N/A  (64-bit)
Function Runtime Version: 4.6.1.18388

[2022-07-29T11:44:57.328Z] Found C:\Users\Andrew J Hughes\QRCodeGen\QRCodeGen.csproj. Using for user secrets file configuration.

Functions:

      Form: [GET] http://localhost:7071/api/Form

      GenerateQRCode: [GET] http://localhost:7071/api/GenerateQRCode

For detailed output, run func with --verbose flag.

In your browser, navigate to

http://localhost:{PORT}/api/Form

{PORT} being replaced with the port number randomly assigned by Azure.


Project Requirements

"You must create at least one class,

line 58 of the ReturnObject.cs class

then create at least one object of that class and populate it with data.

lines 49 -55 of the QRCodeGen.cs class

You must use or display the data in your application."

line 55 of the QRCodeGen.cs class


Create and call at least 3 functions or methods, at least one of which must return a value that is used in your application.

methods and/or functions include GenerateQRCode, Form, ReadAllText, GetBytes, LogInformation, EncodeText, ToPng and ToBase64String


Feature List

  1. "Read data from an external file, such as text, JSON, CSV, etc and use that data in your application."
string indexPage = File.ReadAllText(context.FunctionAppDirectory + "/www/index.html");

The ReadAllText method opens a text file, reads all the text in the file, and then closes the file. It returns a string containing all the text in the index.html file which we then add to the content section of our HttpResponseMessage's header.


  1. "Build a conversion tool that converts user input to another type and displays it (ex: converts cups to grams)."
// get QR text from query string 
string qrtext = req.Query["qrtext"];
log.LogInformation("Generating QR Code for {0}", qrtext);

var qr = QrCode.EncodeText(qrtext, QrCode.Ecc.Medium);
// convert it into a byte array for PNG output
var pngout = qr.ToPng(10, 1, SkiaSharp.SKColors.Black, SkiaSharp.SKColors.White);

There are two conversions happening here. 1) using the EncodeText method of the QrCode class, we encode the text from the query string into a QR code. We then convert the QR code into a PNG image using the ToPng method. 2) the byte array returned for the PNG output is converted to a base64 string and added to the ReturnObject.


  1. see above!

  1. "Visualize data in a graph, chart, or other visual representation of data."

The ToPng method returns a bitmap representing the QR code.


screenshot of program

About

QRCodeGen is the final project for the Code Louisville May 2022 Software Developer course 1 cohort. It is an Azure Function that runs locally and has been tested on a machine installed with Windows (64-bit) using Visual Studio Code.

Topics

Resources

Stars

Watchers

Forks

Sponsor this project