Skip to content
Snippets Groups Projects
Commit 22a831e7 authored by Mia Wang's avatar Mia Wang
Browse files

change backbone

parent 550daa53
No related branches found
No related tags found
No related merge requests found
No preview for this file type
FLASK_APP=react_app.py
FLASK_ENV=development
\ No newline at end of file
from flask import Flask
api = Flask(__name__)
@api.route('/profile')
def my_profile():
response_body = {
"name": "Nagato",
"about" :"Hello! I'm a full stack developer that loves python and javascript"
}
return response_body
\ No newline at end of file
......@@ -17,7 +17,5 @@ app = create_app()
port = int(os.environ.get("PORT", 5000))
if __name__ == '__main__':
app.run(debug=True)
\ No newline at end of file
......@@ -7,32 +7,59 @@ import axios from "axios";
function App() {
// const [formData, setFormData] = useState(null)
const [formData, setFormData] = useState(null)
// function getData() {
// axios({
// method: "POST",
// url:"/profile",
// })
// .then((response) => {
// const res =response.data
// setProfileData(({
// profile_name: res.name,
// about_me: res.about}))
// }).catch((error) => {
// if (error.response) {
// console.log(error.response)
// console.log(error.response.status)
// console.log(error.response.headers)
// }
// })}
//end of new line
function getData() {
axios({
method: "POST",
url:"/profile",
})
.then((response) => {
const res =response.data
setProfileData(({
profile_name: res.name,
about_me: res.about}))
}).catch((error) => {
if (error.response) {
console.log(error.response)
console.log(error.response.status)
console.log(error.response.headers)
}
})}
return (
<div>
<Home />
</div>
);
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
{/* new line start*/}
<p>To get your profile details: </p><button onClick={getData}>Click me</button>
{profileData && <div>
<p>Profile name: {profileData.profile_name}</p>
<p>About me: {profileData.about_me}</p>
</div>
}
{/* end of new line */}
</header>
</div>
);
// return (
// <div>
// <Home />
// </div>
// );
}
export default App;
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