Skip to content

Instantly share code, notes, and snippets.

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}`
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
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"]
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
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);
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;
}
// 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
// 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
@mjzone
mjzone / public.js
Last active June 24, 2020 17:12
public access level
// 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)} />