updated code to include cors

This commit is contained in:
Solomon Laing 2021-06-06 12:23:50 +09:30
parent 6664f307be
commit fa0d8a2ed7
3 changed files with 24 additions and 20 deletions

View File

@ -22,12 +22,6 @@ To run the development server run, you MUST have run `pip install` first:
gunicorn -c gunicorn.config.py dev:api gunicorn -c gunicorn.config.py dev:api
``` ```
Due to production container using .pipfiles and pipenv make sure to run the following to regenerate the pip files before a release commit:
```shell
# Run this in dev container
pipenv install -r requirements.txt
```
## Caveats ## Caveats
Currently there is no git in the container so you can't see what's been edited or not, git will have to be managed from the host. Currently there is no git in the container so you can't see what's been edited or not, git will have to be managed from the host.

2
app.py
View File

@ -2,6 +2,7 @@ from bs4 import BeautifulSoup
from markdown import markdown from markdown import markdown
from flask import Flask from flask import Flask
from flask_restful import Api, Resource, reqparse from flask_restful import Api, Resource, reqparse
from flask_cors import CORS
import random import random
import os import os
@ -95,6 +96,7 @@ def _add_a_attrs(soup):
api = Flask(__name__) api = Flask(__name__)
CORS(api)
_api = Api(api) _api = Api(api)
_api.add_resource(Post, "/post/<string:slug>") _api.add_resource(Post, "/post/<string:slug>")

View File

@ -1,14 +1,22 @@
# To ensure app dependencies are ported from your virtual environment/host machine into your container, run 'pip freeze > requirements.txt' in the terminal to overwrite this file
flask==1.1.2
gunicorn==20.0.4
aniso8601==9.0.1 aniso8601==9.0.1
appdirs==1.4.4
beautifulsoup4==4.9.3 beautifulsoup4==4.9.3
certifi==2021.5.30
click==8.0.1 click==8.0.1
distlib==0.3.2
filelock==3.0.12
Flask==1.1.2
Flask-Cors==3.0.10
Flask-RESTful==0.3.9 Flask-RESTful==0.3.9
gunicorn==20.0.4
itsdangerous==2.0.1 itsdangerous==2.0.1
Jinja2==3.0.1 Jinja2==3.0.1
Markdown==3.3.4 Markdown==3.3.4
MarkupSafe==2.0.1 MarkupSafe==2.0.1
pipenv==2021.5.29
pytz==2021.1 pytz==2021.1
six==1.16.0 six==1.16.0
soupsieve==2.2.1 soupsieve==2.2.1
virtualenv==20.4.7
virtualenv-clone==0.5.4
Werkzeug==2.0.1