diff --git a/crisis-react/package.json b/crisis-react/package.json index c5e2673f274255a0f971f4747280449ed365708a..b878f70a65cd2e478adabf0025a6d3afa8fdbaa2 100644 --- a/crisis-react/package.json +++ b/crisis-react/package.json @@ -1,6 +1,7 @@ { "name": "crisis-react", "private": true, + "proxy":"http://localhost:5000/", "version": "0.0.0", "type": "module", "scripts": { diff --git a/crisis-react/src/login.jsx b/crisis-react/src/login.jsx index 1fd6e6a94d3535f3df47821b0b7366f027ba00b4..ef45c2c6e9f00c302f26c7e6306ac1f85dd2088b 100644 --- a/crisis-react/src/login.jsx +++ b/crisis-react/src/login.jsx @@ -1,6 +1,31 @@ import React, { useState } from 'react' import './styles.css'; + +//takes in signup information + +async function PostSignInfo(data) +{ + + try + { + const respone = await fetch("http://127.0.0.1:5000/login", { + method: "POST", // or 'PUT' + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(data), + }); + + + } + + catch (error) { + console.error("Could not upload signup information successfully", error); + } +} + + function Login() { const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); @@ -8,12 +33,15 @@ function Login() { const handleSubmit = (e) => { e.preventDefault(); + PostSignInfo({ username, password }); + + }; const loginForm = ( <div className="login-container"> <h2>Enter Username</h2> - <form onSubmit="{handleSubmit}"> + <form onSubmit={handleSubmit}> <div className="input-group"> <label htmlFor="username">enter username</label> <input diff --git a/crisis_events.db b/crisis_events.db index 345fbc70b40e54405907573f78b1e3c56c59bc32..018b3faf2a762a7dbea3c4a227489df8131acf34 100644 Binary files a/crisis_events.db and b/crisis_events.db differ diff --git a/crisis_events_database_metadata.json b/crisis_events_database_metadata.json index c672fa43285e64f28bbc95644bf3931657cfdb0c..2fb8be4e885acac2df40c1f09bc991957696e5a5 100644 --- a/crisis_events_database_metadata.json +++ b/crisis_events_database_metadata.json @@ -1 +1 @@ -{"Users": 1, "Collections": 3} \ No newline at end of file +{"Users": 0, "Collections": 0} \ No newline at end of file diff --git a/flask_backend.py b/flask_backend.py index 9fd2a2f6fd1c8acfae80cd76acf4fa4cf9a0d30a..daac109b8300c435ec5cf0c993a5d34676312adb 100644 --- a/flask_backend.py +++ b/flask_backend.py @@ -1,8 +1,12 @@ from flask import Flask, request, abort +from flask_cors import CORS from database_api import CrisisEventsDatabase from runtime_import import runtime_import app = Flask(__name__) +#pip install flask-cors +CORS(app) + database:CrisisEventsDatabase = None @@ -30,6 +34,13 @@ def database_debug_view(): </body> </html> """ +@app.route('/login', methods = ['POST']) +def login(): + + data = request.json # Retrieve JSON data from the request + print(f'The login data: {data}') + return 'Login successful', 200 # Return a response to indicate success + @app.route('/database_service', methods=['POST','GET']) @@ -56,12 +67,15 @@ def database_service(): else: abort(400) + + + if __name__ == '__main__': database = runtime_import("database_implementation/")[0].IMPLEMENTATION() database.initialize() - database.create_user("test_user","12345") - database.create_collection(0,"First Collection") - database.create_collection(0,"Second Collection") - database.create_collection(0,"Third Collection") + # database.create_user("test_user","12345") + #database.create_collection(0,"First Collection") + #database.create_collection(0,"Second Collection") + #database.create_collection(0,"Third Collection") app.run() \ No newline at end of file