DominicFinn / cors-example

pissing about in python with summit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mucking about

Dependencies

Server is running on flask.

cd server
pip install -r requirements.txt
cd ..

Server

To run the server

npm run server

Should start on port 5000

Give it a wink and a nudge:

curl -X POST -H "Content-Type: application/json" -d '' http://localhost:5000/

and you will get back

{
    "perks": [1, 2, 3, 4, 5]
}

Well done you.

Client

Just a single page.

to run the client

npm run client

Run the whole lot

npm run start

This uses a library called concurrently to run both the server and the client at the same time. It's fab.

Show CORS working / not working

Remove / comment out the cors header being sent back to the client in server.py:

```python
    #response.headers.add('Access-Control-Allow-Origin', '*')
```

About

pissing about in python with summit


Languages

Language:Shell 29.6%Language:Python 27.3%Language:Nu 22.0%Language:PowerShell 11.4%Language:HTML 9.6%