This file contains hidden or 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
<?xml version="1.0" encoding="utf-8" ?> | |
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
autoReload="true" | |
internalLogLevel="Info" | |
internalLogFile="c:\temp\internal-nlog.txt"> | |
<!-- enable asp.net core layout renderers --> | |
<extensions> | |
<add assembly="NLog.Web.AspNetCore"/> |
This file contains hidden or 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 static IHostBuilder CreateHostBuilder(string[] args) => | |
Host.CreateDefaultBuilder(args) | |
.ConfigureWebHostDefaults(webBuilder => | |
{ | |
webBuilder.UseStartup<Startup>(); | |
}) | |
.ConfigureLogging(logging => | |
{ | |
logging.ClearProviders(); | |
logging.SetMinimumLevel(LogLevel.Trace); |
This file contains hidden or 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Http; | |
using Microsoft.AspNetCore.Mvc; | |
using Microsoft.Extensions.Logging; | |
namespace FileLoggingNlog | |
{ |
This file contains hidden or 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
interval(1000) // run every 1 second | |
.pipe( | |
startWith(0), | |
switchMap(() => /* API or Function call */) | |
) | |
.subscribe( | |
res => {}, | |
error=>{} | |
); |
This file contains hidden or 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
import flask | |
from flask import request, jsonify | |
def main(): | |
query_parameters = request.args | |
number1 = int(request.args.get(‘number1’)) | |
number2 = int(request.args.get(‘number2’)) | |
return jsonify({‘total’: number1+number2}), 200 |
This file contains hidden or 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
import flask | |
from flask import request, jsonify | |
import json | |
def main(): | |
if not request.json: | |
abort(400) | |
jsonBody =request.json[“numbers”] | |
number1=int(jsonBody[0][‘number1’]) | |
number2=int(jsonBody[1][‘number2’]) | |
return jsonify({‘total’:number1+number2}), 200 |
This file contains hidden or 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
import { BrowserModule } from '@angular/platform-browser'; | |
import { NgModule } from '@angular/core'; | |
import { AppRoutingModule } from './app-routing.module'; | |
import { AppComponent } from './app.component'; | |
import {AuthGuardService} from './auth-guard.service'; | |
import { HomeComponent } from './home/home.component' | |
@NgModule({ | |
declarations: [ |
This file contains hidden or 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
import { NgModule } from '@angular/core'; | |
import { Routes, RouterModule } from '@angular/router'; | |
import { HomeComponent } from './home/home.component'; | |
import { AuthenticationGuard } from './authentication.guard'; | |
const routes: Routes = [ | |
{ path: '*', pathMatch: 'full', redirectTo: 'home' }, | |
{ path: 'home', component: HomeComponent, canActivate: [AuthenticationGuard] } | |
]; |
This file contains hidden or 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
import { Injectable } from '@angular/core'; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class AuthGuardService { | |
constructor() { | |
} |
This file contains hidden or 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
import { Injectable } from '@angular/core'; | |
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree } from '@angular/router'; | |
import { Observable } from 'rxjs'; | |
import { AuthGuardService } from './auth-guard.service'; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class AuthenticationGuard implements CanActivate { | |
constructor(private authService: AuthGuardService) { } |
OlderNewer