Skip to content

Commit

Permalink
added http to meta to hanve https or http
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Aug 12, 2020
1 parent f0a4182 commit 0bd53e2
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 9 deletions.
5 changes: 3 additions & 2 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
from pathlib import Path
from bs4 import BeautifulSoup
from slugify import slugify

from routers.fastAPI_socialauth import fastAPI_socialauth

app = FastAPI()
app.include_router(fastAPI_socialauth.router)
#app.add_middleware(HTTPSRedirectMiddleware)

app_path = Path.cwd()
Expand Down Expand Up @@ -530,7 +531,7 @@ async def create_upload_file(upload: bytes = File("upload")):
async def websocket_endpoint(websocket: WebSocket):
await websocket.accept()
while True:

print('is websocket')
data = await websocket.receive_text()
keys = ["type","slug", "title", "author", "text","grid"]
data = dict(zip(keys, data.split("💾🥞")[1:]))
Expand Down
9 changes: 9 additions & 0 deletions app/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@ certifi==2020.4.5.1
click==7.1.1
coolname==1.1.0
fastapi==0.54.1
google==2.0.2
google-api-python-client==1.7.8
google-auth==1.6.3
google-auth-httplib2==0.0.3
google-auth-oauthlib==0.3.0
h11==0.9.0
httptools==0.1.1
Jinja2==2.11.2
MarkupSafe==1.1.1
oauth2client==4.1.3
passlib
pydantic==1.5.1
python-slugify==4.0.0
python-multipart
python-jose==3.2.0
PyYAML==5.3.1
soupsieve==2.0
starlette==0.13.2
Expand All @@ -19,3 +27,4 @@ Unidecode==1.1.1
uvicorn==0.11.3
uvloop==0.14.0
websockets==8.1
httplib2
3 changes: 2 additions & 1 deletion app/site/site.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
course_name: "World History at Global Scale"
course_name: "Global History of Geese"
course_id: "HIST101"
description: "A class for all who live on this blue marble."

url: "blini.apjan.co"
http: "https"
dev: true
# change header/footer gradient css?
#theme: fun
2 changes: 1 addition & 1 deletion app/templates/edit_essay.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
licenseKey: '',
simpleUpload: {
// The URL the images are uploaded to.
uploadUrl: 'http://{{ meta.url }}/images',
uploadUrl: '{{ meta.http }}://{{ meta.url }}/images',

// Headers sent along with the XMLHttpRequest to the upload server.
},
Expand Down
6 changes: 3 additions & 3 deletions app/templates/edit_exhibit.html
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ <h4 class="modal-title">Edit Item</h4>
if (typeof files !== "undefined") {
fd.append('file',files);
fd.append('filename', files.name);
request.open("POST", "https://{{ meta.url }}/item_images");
request.open("POST", "{{ meta.http }}://{{ meta.url }}/item_images");
request.send(fd);
let ur = request.response;
let url = ur.slice(2,-2);
Expand Down Expand Up @@ -375,7 +375,7 @@ <h4 class="modal-title">Edit Item</h4>
licenseKey: '',
simpleUpload: {
// The URL the images are uploaded to.
uploadUrl: 'http://{{ meta.url }}/images',
uploadUrl: '{{ meta.http }}://{{ meta.url }}/images',

// Headers sent along with the XMLHttpRequest to the upload server.
},
Expand Down Expand Up @@ -623,7 +623,7 @@ <h4 class="modal-title">Edit Item</h4>
licenseKey: '',
simpleUpload: {
// The URL the images are uploaded to.
uploadUrl: 'http://{{ meta.url }}/images',
uploadUrl: '{{ meta.http }}://{{ meta.url }}/images',

// Headers sent along with the XMLHttpRequest to the upload server.
},
Expand Down
6 changes: 4 additions & 2 deletions app/templates/edit_item.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<script src="https://ckeditor.com/apps/ckfinder/3.5.0/ckfinder.js"></script>

<script>
function isOpen(ws) { return ws.readyState === ws.OPEN }
let ws = new WebSocket("ws://{{ meta.url }}/essay-ws");
let editor;

Expand Down Expand Up @@ -103,7 +104,7 @@
licenseKey: '',
simpleUpload: {
// The URL the images are uploaded to.
uploadUrl: 'http://localhost:8000/images',
uploadUrl: '{{ meta.http }}://{{ meta.url }}/images',

// Headers sent along with the XMLHttpRequest to the upload server.
},
Expand All @@ -121,8 +122,9 @@
const author = $("#author").text();
// data = '{"slug": "{{ the.slug }}","title": "' + title + '" , "author": "'+ author + '", "text": "' + text + '" }';
data = '💾🥞' + '{{ the.slug }}' + '💾🥞' + title + '💾🥞' + author + '💾🥞' +text
if (!isOpen(socket)) return;
ws.send(data);
});
});
} )
.catch( error => {
console.error( error );
Expand Down
1 change: 1 addition & 0 deletions start_docker
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ docker run -d \

echo "🐳 Successfully started docker 🐳"


0 comments on commit 0bd53e2

Please sign in to comment.