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
app.get('/bye', function(req, res) { | |
res.send({ | |
"Output": "bye" | |
}); | |
}); |
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
app.get('/', function(req, res) { | |
res.send({ | |
"Output": "Hello get2 " | |
}); | |
}); | |
app.post('/', function(req, res) { | |
console.log('body = ' + req.body); | |
var name = req.body.name; | |
res.send({ |
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
private static async Task<Person> Identify(FaceClient client, string personGroupId, string imageUrl) | |
{ | |
var detectedFaces = new List<DetectedFace>((await client.Face.DetectWithUrlAsync(imageUrl)).ToArray()); | |
var found = await client.Face.IdentifyAsync(detectedFaces.Select(df => df.FaceId).ToList(), personGroupId); | |
var personId = found.First().Candidates.First().PersonId; | |
return await client.PersonGroupPerson.GetAsync(personGroupId, personId); | |
} |
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
static async Task Main(string[] args) | |
{ | |
// 1. Create a client | |
var client = new FaceClient(new ApiKeyServiceClientCredentials(subKey)) | |
{ | |
Endpoint = endpoint | |
}; | |
// 2. Create a Person Group | |
const string personGroupName = "DPL2"; |
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
static async Task Main(string[] args) | |
{ | |
// create a client | |
var client = new FaceClient(new ApiKeyServiceClientCredentials(subKey)) | |
{ | |
Endpoint = endpoint | |
}; | |
// image with 3 faces | |
var url = "https://dontpaniclabs.com/wp-content/uploads/2020/01/hero_layer.jpg"; |
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
[Authorize] | |
[ApiController] | |
[Route("[controller]")] | |
public class TestController : Controller | |
{ | |
// GET | |
public JsonResult Index() | |
{ | |
return Json("hi"); | |
} |
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
[ApiController] | |
[Route("[controller]")] | |
public class AuthController : Controller | |
{ | |
// GET | |
[HttpGet] | |
public string Token() | |
{ | |
var tokenHandler = new JwtSecurityTokenHandler(); | |
var key = Encoding.ASCII.GetBytes("YOUR_KEY"); |
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
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddControllers(); | |
var key = Encoding.ASCII.GetBytes("YOUR_KEY"); | |
services.AddAuthentication(x => | |
{ | |
x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; | |
x.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; | |
}) |
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
// Call the method using reflection | |
var result = methodInfo.Invoke(_contactManager, parameterList.ToArray()); | |
return Json(result); |
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
// Map parameters on method to data from JSON | |
var parameterList = new List<object>(); | |
foreach (var parameterInfo in methodInfo.GetParameters()) | |
{ | |
var helpObj = Activator.CreateInstance(parameterInfo.ParameterType); | |
help.Add(helpObj); | |
var pJson = parameters[parameterInfo.Name] as JObject; | |
var pObj = pJson.ToObject(parameterInfo.ParameterType); | |
parameterList.Add(pObj); |
NewerOlder