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 React, { useState } from 'react'; | |
function App() { | |
const [number, setNumber] = useState(""); | |
const [result, setResult] = useState(""); | |
const handleSubmit = async (event) => { | |
event.preventDefault(); | |
fetch( | |
`https://enlearacademy.tk/generate/${number}` |
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 * as cdk from "@aws-cdk/core"; | |
import { Vpc } from "@aws-cdk/aws-ec2"; | |
import * as ecs from "@aws-cdk/aws-ecs"; | |
import * as ecs_patterns from "@aws-cdk/aws-ecs-patterns"; | |
export class FargateDemoStack extends cdk.Stack { | |
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) { | |
super(scope, id, props); | |
// VPC |
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
FROM alpine:latest | |
RUN apk add --no-cache nodejs npm | |
WORKDIR /app | |
COPY package.json /app | |
RUN npm install | |
COPY . /app | |
EXPOSE 3000 | |
CMD ["npm", "start"] |
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
const express = require("express"); | |
const app = express(); | |
// Health check endpoint | |
app.get("/health", (req, res) => { | |
res.status(200); | |
res.send("healthy"); | |
}); | |
// Calculating the fibonacci value |
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 React, { useState } from 'react'; | |
import './App.css'; | |
// Import Amplify and Storage | |
import Amplify, { Storage } from 'aws-amplify'; | |
// withAuthenticator is a higher order component that wraps the application with a login page | |
import { withAuthenticator } from '@aws-amplify/ui-react'; | |
// Import the project config files and configure them with Amplify | |
import awsconfig from './aws-exports'; | |
Amplify.configure(awsconfig); |
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
const generateDownloadURL = async () => { | |
// Creating a video download url that expires in 5 minutes or 300 seconds | |
const URL = Storage.get('react-introduction.mp4', { expires: 300 }); | |
return URL; | |
} |
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
// Set the "level" attribute value to "private" | |
const handleChange = async (e) => { | |
const file = e.target.files[0]; | |
await Storage.put('picture.jpg', file, { | |
contentType: 'image/jpg', | |
level: 'private' | |
}); | |
} | |
// HTML |
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
// Set the "level" attribute value to "protected" | |
const handleChange = async (e) => { | |
const file = e.target.files[0]; | |
await Storage.put('picture.jpg', file, { | |
contentType: 'image/jpg', | |
level: 'protected' | |
}); | |
} | |
// HTML |
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
// The default access level of the uploads is "public" | |
const handleChange = async (e) => { | |
const file = e.target.files[0]; | |
await Storage.put('picture.jpg', file, { | |
contentType: 'image/jpg' | |
}); | |
} | |
// HTML | |
<input type="file" accept='image/jpg' onChange={(evt) => handleChange(evt)} /> |