├── photo_2020-11-24_19-13-04.jpg ├── templates ├── index.html ├── home.html ├── login.html └── upload.html └── app.py /photo_2020-11-24_19-13-04.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PrinceKumawat1109/AWS-PROJECT/HEAD/photo_2020-11-24_19-13-04.jpg -------------------------------------------------------------------------------- /templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 53 | 54 | 55 |
56 |

Register Form

57 |
58 | 59 | 60 |
61 | 62 |
63 | 64 | 65 |
66 | 67 |
68 | 69 | 70 |
71 | 72 | 73 |
74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /templates/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | HackerShrine dynamoDB 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 22 |
23 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /templates/login.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 70 | 71 | 72 | 73 | 74 |
75 |
76 |

Login

77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 |
86 |
87 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /templates/upload.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | HackerShrine 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 34 |
35 | 36 | 37 |
38 |

Hello upload ur photo

39 |
40 |
41 |
42 |

Choose a file to upload it to AWS S3

43 | 44 |
45 | 46 |
47 | {{msg}} 48 |
49 |
50 |
51 |
52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, render_template, request 2 | import boto3 3 | app = Flask(__name__) 4 | dynamodb = boto3.resource('dynamodb', 5 | aws_access_key_id='AKIAYKK6KRNVJBIC7TVD', 6 | aws_secret_access_key='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', 7 | ) 8 | from boto3.dynamodb.conditions import Key, Attr 9 | from werkzeug.utils import secure_filename 10 | s3 = boto3.client('s3', 11 | # aws_access_key_id='**', 12 | aws_access_key_id='AKIAYKK6KRNVJBIC7TVD', 13 | # aws_secret_access_key='**', 14 | aws_secret_access_key='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', 15 | ) 16 | BUCKET_NAME = 'upload181229' 17 | @app.route('/') 18 | def index(): 19 | return render_template('index.html') 20 | @app.route('/signup', methods=['post']) 21 | def signup(): 22 | if request.method == 'POST': 23 | name = request.form['name'] 24 | email = request.form['email'] 25 | password = request.form['password'] 26 | table = dynamodb.Table('users') 27 | table.put_item( 28 | Item={ 29 | 'name': name, 30 | 'email': email, 31 | 'password': password 32 | } 33 | ) 34 | msg = "Registration Complete. Please Login to your account !" 35 | return render_template('login.html', msg=msg) 36 | return render_template('index.html') 37 | @app.route('/login') 38 | def login(): 39 | return render_template('login.html') 40 | @app.route('/check', methods=['post']) 41 | def check(): 42 | if request.method == 'POST': 43 | email = request.form['email'] 44 | password = request.form['password'] 45 | table = dynamodb.Table('users') 46 | response = table.query( 47 | KeyConditionExpression=Key('email').eq(email) 48 | ) 49 | items = response['Items'] 50 | name = items[0]['name'] 51 | print(items[0]['password']) 52 | if password == items[0]['password']: 53 | return render_template("home.html", name=name) 54 | return render_template("login.html") 55 | @app.route('/home') 56 | def home(): 57 | return render_template('home.html') 58 | @app.route('/profile') 59 | def profile(): 60 | return render_template("upload.html") 61 | @app.route('/upload', methods=['post']) 62 | def upload(): 63 | if request.method == 'POST': 64 | img = request.files['file'] 65 | if img: 66 | filename = secure_filename(img.filename) 67 | img.save(filename) 68 | s3.upload_file( 69 | Bucket=BUCKET_NAME, 70 | Filename=filename, 71 | Key=filename 72 | ) 73 | msg = "Upload Done ! " 74 | return render_template("upload.html", msg=msg) 75 | if __name__ == "__main__": 76 | app.run(debug=True) --------------------------------------------------------------------------------