Skip to content

Commit 41605e7

Browse files
committed
2️⃣ Initial support for Deta Space's Alpha
1 parent f375dc8 commit 41605e7

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
static/tailwind-dev.css
55
node_modules
66
templates/testing-files.html
7+
.space/meta

Spacefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Spacefile Docs: https://go.deta.dev/docs/spacefile/v0
2+
v: 0
3+
micros:
4+
- name: deta-vc-cms-cdn
5+
src: .
6+
engine: python3.9
7+
primary: true
8+
public_routes:
9+
- "/file/*"
10+
- "/api/collection/*"
11+
- "/api/content/*"
12+
- "/api/collections"
13+
icon: berowra.png

berowra.png

6.83 KB
Loading

main.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def new():
133133
"templateItems": finalData,
134134
"lastUpdated": str(datetime.datetime.now(utc))
135135
})
136-
return redirect(f"{path}{host}/")
136+
return redirect(f"/")
137137
else:
138138
return render_template('new.html')
139139

@@ -166,7 +166,7 @@ def collectionAddField(id):
166166
"type": request.form['fieldType']
167167
})
168168
collectionsDB.put(data)
169-
return redirect(f"{path}{host}/collection/"+id+"/edit")
169+
return redirect(f"/collection/"+id+"/edit")
170170

171171
@app.route('/collection/<id>/edit/edit-field/<field>', methods=['POST'])
172172
def collectionEditField(id, field):
@@ -179,7 +179,7 @@ def collectionEditField(id, field):
179179
"type": request.form['fieldType']
180180
}
181181
collectionsDB.put(data)
182-
return redirect(f"{path}{host}/collection/"+id+"/edit")
182+
return redirect(f"/collection/"+id+"/edit")
183183

184184
@app.route('/collection/<id>/edit/delete-field/<field>', methods=['GET'])
185185
def collectionDeleteField(id, field):
@@ -188,19 +188,19 @@ def collectionDeleteField(id, field):
188188
if int(templateItem['id']) == int(field):
189189
del data['templateItems'][templateItemIndex]
190190
collectionsDB.put(data)
191-
return redirect(f"{path}{host}/collection/"+id+"/edit")
191+
return redirect(f"/collection/"+id+"/edit")
192192

193193
@app.route('/collection/<id>/delete', methods=['GET'])
194194
def collectionDelete(id):
195195
collectionsDB.delete(id)
196-
return redirect(f"{path}{host}/")
196+
return redirect(f"/")
197197

198198

199199
@app.route('/content/<id>/delete', methods=['GET'])
200200
def contentDelete(id):
201201
contentData = contentDB.get(id)
202202
contentDB.delete(id)
203-
return redirect(f"{path}{host}/collection/"+contentData['collectionKey'])
203+
return redirect(f"/collection/"+contentData['collectionKey'])
204204

205205

206206
@app.route('/content/<id>', methods=['GET', 'POST'])
@@ -240,7 +240,7 @@ def content(id):
240240
contentArray = list(content.items())
241241
contentDB.update({'content': content, 'published': published, 'title': title, 'titleCaps': title.upper(),
242242
"lastUpdated": str(datetime.datetime.now(utc))}, id)
243-
return redirect(f"{path}{host}/collection/{contentData['collectionKey']}")
243+
return redirect(f"/collection/{contentData['collectionKey']}")
244244
getContentData = contentDB.get(id)
245245
getCollectionData = collectionsDB.get(getContentData['collectionKey'])
246246
getContent = getContentData['content']
@@ -280,7 +280,7 @@ def newContent(id):
280280
res = contentDB.insert(
281281
{"collectionKey": id, "content": {}, "title": "Unnamed Content", "published": False, "lastUpdated": str(datetime.datetime.now(utc))})
282282
print(res)
283-
return redirect(f"{path}{host}/content/" + res['key'])
283+
return redirect(f"/content/" + res['key'])
284284

285285

286286
@app.route('/api/content/<id>', methods=['GET'])

0 commit comments

Comments
 (0)