Skip to content

Commit b528a8a

Browse files
committed
add start-django-dipper
1 parent 0f8c116 commit b528a8a

File tree

11 files changed

+73
-119
lines changed

11 files changed

+73
-119
lines changed

web-framework/python/django/publish.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
Edition: 3.0.0
22
Type: Project
3-
Name: start-django-v3
3+
Name: start-django-dipper
44
Provider:
55
- 阿里云
6-
Version: 0.0.7
6+
Version: 0.0.1
77
Description: 本案例是将 Python Web 框架中,非常受欢迎的 Django 框架,快速创建并部署到阿里云函数计算 FC。
8-
HomePage: https://github.com/devsapp/start-web-framework
8+
HomePage: https://github.com/devsapp/start-web-framework/tree/dipper/web-framework/python/django
99
Organization: 阿里云函数计算(FC)
1010
Effective: Public
1111
Tags:

web-framework/python/django/readme.md

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
11

22
> 注:当前项目为 Serverless Devs 应用,由于应用中会存在需要初始化才可运行的变量(例如应用部署地区、函数名等等),所以**不推荐**直接 Clone 本仓库到本地进行部署或直接复制 s.yaml 使用,**强烈推荐**通过 `s init ${模版名称}` 的方法或应用中心进行初始化,详情可参考[部署 & 体验](#部署--体验)
33
4-
# start-django-v3 帮助文档
5-
<p align="center" class="flex justify-center">
6-
<a href="https://www.serverless-devs.com" class="ml-1">
7-
<img src="http://editor.devsapp.cn/icon?package=start-django-v3&type=packageType">
8-
</a>
9-
<a href="http://www.devsapp.cn/details.html?name=start-django-v3" class="ml-1">
10-
<img src="http://editor.devsapp.cn/icon?package=start-django-v3&type=packageVersion">
11-
</a>
12-
<a href="http://www.devsapp.cn/details.html?name=start-django-v3" class="ml-1">
13-
<img src="http://editor.devsapp.cn/icon?package=start-django-v3&type=packageDownload">
14-
</a>
15-
</p>
4+
# start-django-dipper 帮助文档
165

176
<description>
187

@@ -22,7 +11,7 @@
2211

2312
<codeUrl>
2413

25-
- [:smiley_cat: 代码](https://github.com/devsapp/start-web-framework/tree/V3/web-framework/python/django/src)
14+
2615

2716
</codeUrl>
2817
<preview>
@@ -62,17 +51,11 @@
6251

6352
<appcenter>
6453

65-
- :fire: 通过 [Serverless 应用中心](https://fcnext.console.aliyun.com/applications/create?template=start-django-v3)
66-
[![Deploy with Severless Devs](https://img.alicdn.com/imgextra/i1/O1CN01w5RFbX1v45s8TIXPz_!!6000000006118-55-tps-95-28.svg)](https://fcnext.console.aliyun.com/applications/create?template=start-django-v3) 该应用。
54+
:fire: 通过 [Dipper 应用中心](https://devs.console.aliyun.com/applications/createtemplate=start-django-dipper)[![Deploy with Severless Devs](https://img.alicdn.com/imgextra/i1/O1CN01w5RFbX1v45s8TIXPz_!!6000000006118-55-tps-95-28.svg)](https://devs.console.aliyun.com/applications/createtemplate=start-django-dipper) 该应用。
6755

6856
</appcenter>
6957
<deploy>
70-
71-
- 通过 [Serverless Devs Cli](https://www.serverless-devs.com/serverless-devs/install) 进行部署:
72-
- [安装 Serverless Devs Cli 开发者工具](https://www.serverless-devs.com/serverless-devs/install) ,并进行[授权信息配置](https://docs.serverless-devs.com/fc/config)
73-
- 初始化项目:`s init start-django-v3 -d start-django-v3`
74-
- 进入项目,并进行项目部署:`cd start-django-v3 && s deploy -y`
75-
58+
7659
</deploy>
7760

7861
## 案例介绍
@@ -96,17 +79,9 @@ Django还具有高度的安全性,包括防止常见的Web攻击、CSRF保护
9679
<usedetail id="flushContent">
9780

9881
### 查看部署的案例
99-
部署完成之后,您可以看到系统返回给您的案例地址, 如图:
100-
101-
![图片alt](https://img.alicdn.com/imgextra/i4/O1CN019DHro51NlQYyyFzn7_!!6000000001610-0-tps-1104-322.jpg)
102-
103-
此时,打开案例地址,就可以进入 django 默认的首页:
104-
105-
![图片alt](https://img.alicdn.com/imgextra/i4/O1CN01dS1RL71CEUJCVIj2I_!!6000000000049-0-tps-1814-1278.jpg)
106-
107-
### 二次开发
82+
部署完成之后,您可以看到系统返回给您的案例地址, 打开案例地址,就可以看到如下图:
10883

109-
您可以通过云端控制台的开发功能进行二次开发。如果您之前是在本地创建的项目案例,也可以在本地项目目录`start-django-v3`文件夹下,对项目进行二次开发。开发完成后,可以通过`s deploy`进行快速部署。
84+
![图片alt](https://img.alicdn.com/imgextra/i1/O1CN01FlMugC1k8FwHLLTYb_!!6000000004638-0-tps-1574-644.jpg)
11085

11186
</usedetail>
11287

@@ -125,7 +100,7 @@ Django还具有高度的安全性,包括防止常见的Web攻击、CSRF保护
125100

126101
<p align="center">
127102

128-
| <img src="https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1635407298906_20211028074819117230.png" width="130px" > | <img src="https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1635407044136_20211028074404326599.png" width="130px" > | <img src="https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1635407252200_20211028074732517533.png" width="130px" > |
103+
| <img src="https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1635407298906_20211028074819117230.png" width="130px" > | <img src="https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1635407044136_20211028074404326599.png" width="130px" > | <img src="https://images.devsapp.cn/fc-faq/33947367.png" width="130px" > |
129104
| --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
130105
| <center>微信公众号:`serverless`</center> | <center>微信小助手:`xiaojiangwh`</center> | <center>钉钉交流群:`33947367`</center> |
131106
</p>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
start_django:
2+
defaultBuilder:
3+
languages:
4+
- python3.10
5+
steps:
6+
- run: mkdir -p python
7+
path: ./code
8+
- run: pip install -r requirements.txt -t ./python
9+
path: ./code

web-framework/python/django/src/code/.fcignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

web-framework/python/django/src/code/HelloWorld/urls.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import index.views
1919

2020
urlpatterns = [
21-
path('', index.views.index),
21+
path('<path:path>/', index.views.default),
22+
path('', index.views.index)
2223
# path('admin/', admin.site.urls),
2324
]
Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,31 @@
1-
from django.shortcuts import render, HttpResponse
2-
3-
4-
# Create your views here.
5-
1+
from django.http import JsonResponse
2+
import json
3+
import arrow
64

75
# Create your views here.
86
def index(request):
9-
return HttpResponse('''<html xmlns="http://www.w3.org/1999/xhtml">
10-
<head>
11-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
12-
<title>Serverless Devs - Powered By Serverless Devs</title>
13-
<link href="https://example-static.oss-cn-beijing.aliyuncs.com/web-framework/style.css" rel="stylesheet" type="text/css"/>
14-
</head>
15-
<body>
16-
<div class="website">
17-
<div class="ri-t">
18-
<h1>Devsapp</h1>
19-
<h2>这是一个 Django 项目</h2>
20-
<span>自豪地通过Serverless Devs进行部署</span>
21-
<br/>
22-
<p>您也可以快速体验: <br/>
23-
• 下载Serverless Devs工具:npm install @serverless-devs/s<br/>
24-
• 初始化项目:s init start-django-v3<br/>
7+
body_str = request.body.decode('utf-8')
8+
response_content = {
9+
"msg": "Hello, World!" + " at " + arrow.now().format("YYYY-MM-DD HH:mm:ss"),
10+
"request": {
11+
"query": dict(request.GET),
12+
"path": "",
13+
"data": body_str,
14+
"clientIp": request.META.get('REMOTE_ADDR'),
15+
},
16+
}
17+
return JsonResponse(response_content)
18+
2519

26-
• 项目部署:s deploy<br/>
27-
<br/>
28-
Serverless Devs 钉钉交流群:33947367
29-
</p>
30-
</div>
31-
</div>
32-
</body>
33-
</html>''')
20+
def default(request, path):
21+
body_str = request.body.decode('utf-8')
22+
response_content = {
23+
"msg": "Hello, World!" + " at " + arrow.now().format("YYYY-MM-DD HH:mm:ss"),
24+
"request": {
25+
"query": dict(request.GET),
26+
"path": path,
27+
"data": body_str,
28+
"clientIp": request.META.get('REMOTE_ADDR'),
29+
},
30+
}
31+
return JsonResponse(response_content)
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
asgiref==3.3.1
22
Django==3.1.7
33
pytz==2021.1
4-
sqlparse==0.4.1
4+
sqlparse==0.4.1
5+
arrow==1.3.0

web-framework/python/django/src/readme.md

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
11

22
> 注:当前项目为 Serverless Devs 应用,由于应用中会存在需要初始化才可运行的变量(例如应用部署地区、函数名等等),所以**不推荐**直接 Clone 本仓库到本地进行部署或直接复制 s.yaml 使用,**强烈推荐**通过 `s init ${模版名称}` 的方法或应用中心进行初始化,详情可参考[部署 & 体验](#部署--体验)
33
4-
# start-django-v3 帮助文档
5-
<p align="center" class="flex justify-center">
6-
<a href="https://www.serverless-devs.com" class="ml-1">
7-
<img src="http://editor.devsapp.cn/icon?package=start-django-v3&type=packageType">
8-
</a>
9-
<a href="http://www.devsapp.cn/details.html?name=start-django-v3" class="ml-1">
10-
<img src="http://editor.devsapp.cn/icon?package=start-django-v3&type=packageVersion">
11-
</a>
12-
<a href="http://www.devsapp.cn/details.html?name=start-django-v3" class="ml-1">
13-
<img src="http://editor.devsapp.cn/icon?package=start-django-v3&type=packageDownload">
14-
</a>
15-
</p>
4+
# start-django-dipper 帮助文档
165

176
<description>
187

@@ -22,7 +11,7 @@
2211

2312
<codeUrl>
2413

25-
- [:smiley_cat: 代码](https://github.com/devsapp/start-web-framework/tree/V3/web-framework/python/django/src)
14+
2615

2716
</codeUrl>
2817
<preview>
@@ -62,17 +51,11 @@
6251

6352
<appcenter>
6453

65-
- :fire: 通过 [Serverless 应用中心](https://fcnext.console.aliyun.com/applications/create?template=start-django-v3)
66-
[![Deploy with Severless Devs](https://img.alicdn.com/imgextra/i1/O1CN01w5RFbX1v45s8TIXPz_!!6000000006118-55-tps-95-28.svg)](https://fcnext.console.aliyun.com/applications/create?template=start-django-v3) 该应用。
54+
:fire: 通过 [Dipper 应用中心](https://devs.console.aliyun.com/applications/createtemplate=start-django-dipper)[![Deploy with Severless Devs](https://img.alicdn.com/imgextra/i1/O1CN01w5RFbX1v45s8TIXPz_!!6000000006118-55-tps-95-28.svg)](https://devs.console.aliyun.com/applications/createtemplate=start-django-dipper) 该应用。
6755

6856
</appcenter>
6957
<deploy>
70-
71-
- 通过 [Serverless Devs Cli](https://www.serverless-devs.com/serverless-devs/install) 进行部署:
72-
- [安装 Serverless Devs Cli 开发者工具](https://www.serverless-devs.com/serverless-devs/install) ,并进行[授权信息配置](https://docs.serverless-devs.com/fc/config)
73-
- 初始化项目:`s init start-django-v3 -d start-django-v3`
74-
- 进入项目,并进行项目部署:`cd start-django-v3 && s deploy -y`
75-
58+
7659
</deploy>
7760

7861
## 案例介绍
@@ -96,17 +79,9 @@ Django还具有高度的安全性,包括防止常见的Web攻击、CSRF保护
9679
<usedetail id="flushContent">
9780

9881
### 查看部署的案例
99-
部署完成之后,您可以看到系统返回给您的案例地址, 如图:
100-
101-
![图片alt](https://img.alicdn.com/imgextra/i4/O1CN019DHro51NlQYyyFzn7_!!6000000001610-0-tps-1104-322.jpg)
102-
103-
此时,打开案例地址,就可以进入 django 默认的首页:
104-
105-
![图片alt](https://img.alicdn.com/imgextra/i4/O1CN01dS1RL71CEUJCVIj2I_!!6000000000049-0-tps-1814-1278.jpg)
106-
107-
### 二次开发
82+
部署完成之后,您可以看到系统返回给您的案例地址, 打开案例地址,就可以看到如下图:
10883

109-
您可以通过云端控制台的开发功能进行二次开发。如果您之前是在本地创建的项目案例,也可以在本地项目目录`start-django-v3`文件夹下,对项目进行二次开发。开发完成后,可以通过`s deploy`进行快速部署。
84+
![图片alt](https://img.alicdn.com/imgextra/i1/O1CN01FlMugC1k8FwHLLTYb_!!6000000004638-0-tps-1574-644.jpg)
11085

11186
</usedetail>
11287

@@ -125,7 +100,7 @@ Django还具有高度的安全性,包括防止常见的Web攻击、CSRF保护
125100

126101
<p align="center">
127102

128-
| <img src="https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1635407298906_20211028074819117230.png" width="130px" > | <img src="https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1635407044136_20211028074404326599.png" width="130px" > | <img src="https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1635407252200_20211028074732517533.png" width="130px" > |
103+
| <img src="https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1635407298906_20211028074819117230.png" width="130px" > | <img src="https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1635407044136_20211028074404326599.png" width="130px" > | <img src="https://images.devsapp.cn/fc-faq/33947367.png" width="130px" > |
129104
| --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
130105
| <center>微信公众号:`serverless`</center> | <center>微信小助手:`xiaojiangwh`</center> | <center>钉钉交流群:`33947367`</center> |
131106
</p>
Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
# ------------------------------------
2-
# 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3
3-
# 有问题快来钉钉群问一下吧:33947367
4-
# ------------------------------------
5-
61
edition: 3.0.0
72
name: start-django-app
83
access: '{{ access }}'
94
vars:
105
region: '{{ region }}'
11-
functionName: '{{ functionName }}'
6+
127
resources:
138
start_django:
149
component: fc3
@@ -18,7 +13,8 @@ resources:
1813
path: ./code
1914
props:
2015
region: ${vars.region}
21-
description: Serverless Devs Web Framework Function
16+
functionName: '{{ functionName }}'
17+
description: Dipper django function
2218
runtime: custom.debian10
2319
customRuntimeConfig:
2420
command:
@@ -28,15 +24,15 @@ resources:
2824
- "runserver"
2925
- "0.0.0.0:9000"
3026
timeout: 60
31-
functionName: ${vars.functionName}
27+
environmentVariables:
28+
PATH: /var/fc/lang/python3.10/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/ruby/bin:/opt/bin:/code:/code/bin
29+
PYTHONPATH: /opt/python:/code/python:/code
30+
TZ: Asia/Shanghai
3231
code: ./code
33-
fc3_domain_0:
34-
component: fc3-domain
35-
props:
36-
region: ${vars.region}
37-
domainName: auto
38-
protocol: HTTP
39-
routeConfig:
40-
routes:
41-
- path: /*
42-
functionName: ${vars.functionName}
32+
logConfig: auto
33+
customDomain:
34+
domainName: auto
35+
protocol: HTTP
36+
route:
37+
path: /*
38+
qualifier: LATEST

web-framework/python/fastapi/publish.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Type: Project
33
Name: start-fastapi-dipper
44
Provider:
55
- 阿里云
6-
Version: 0.0.1
6+
Version: 0.0.2
77
Description: 本案例是将 fastapi 框架,这一快速且高效的Web框架,快速创建部署到阿里云函数计算 FC 。
88
Organization: 阿里云函数计算(FC)
99
Effective: Public

web-framework/python/fastapi/src/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
start_flask:
1+
start_fastapi:
22
defaultBuilder:
33
languages:
44
- python3.10

0 commit comments

Comments
 (0)