Skip to content
Snippets Groups Projects
Commit 5e14e0ee authored by Santiago Guadiamos's avatar Santiago Guadiamos
Browse files

front-end back-end communication for login info

parent f0514cfa
No related branches found
No related tags found
No related merge requests found
{
"name": "crisis-react",
"private": true,
"proxy":"http://localhost:5000/",
"version": "0.0.0",
"type": "module",
"scripts": {
......
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
......
No preview for this file type
{"Users": 1, "Collections": 3}
\ No newline at end of file
{"Users": 0, "Collections": 0}
\ No newline at end of file
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment