Skip to content

Commit b9ef73c

Browse files
committed
Resolve CORS
1 parent f5ed4dc commit b9ef73c

6 files changed

Lines changed: 25 additions & 58 deletions

File tree

backend/app/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import random
44

55
from flask import Flask, jsonify, request
6+
from flask_cors import CORS
67

78
from backend.blockchain.blockchain import Blockchain
89
from backend.wallet.wallet import Wallet
@@ -11,6 +12,7 @@
1112
from backend.pubsub import PubSub
1213

1314
app = Flask(__name__)
15+
CORS(app, resources={ r'/*': { 'origins': 'http://localhost:3000' } })
1416
blockchain = Blockchain()
1517
wallet = Wallet(blockchain)
1618
transaction_pool = TransactionPool()

frontend/src/App.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

frontend/src/Joke.js

Lines changed: 0 additions & 24 deletions
This file was deleted.

frontend/src/components/App.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React, { useState, useEffect } from 'react';
2+
import logo from '../assets/logo.png';
3+
4+
function App() {
5+
const [walletInfo, setWalletInfo] = useState({});
6+
7+
useEffect(() => {
8+
fetch('http://localhost:5000/wallet/info')
9+
.then(response => response.json())
10+
.then(json => setWalletInfo(json));
11+
});
12+
13+
return (
14+
<div className="App">
15+
<img className="logo" src={logo} alt="application-logo" />
16+
<h3>Welcome to pychain</h3>
17+
</div>
18+
);
19+
}
20+
21+
export default App;

frontend/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
33
import './index.css';
4-
import App from './App';
4+
import App from './components/App';
55

66
ReactDOM.render(<App />, document.getElementById('root'));

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ Flask==1.1.1
33
pubnub==4.1.6
44
requests==2.22.0
55
cryptography==2.7
6+
Flask-Cors==3.0.8

0 commit comments

Comments
 (0)