Git Product home page Git Product logo

python-executor's Introduction

python-executor

使用阿里云函数计算(Aliyun Function Compute)搭建的一个在线 Python 代码执行器,带你几乎零成本体验 Serverless 技术。

部署步骤

创建函数

前往阿里云,免费开通函数计算服务(选择后付费模式),创建服务和函数,语言选择 python3

自动部署

使用 GitHub Action 可以将项目自动部署至函数计算。使用时需配置以下的环境变量:

  • FUNCTION_COMPUTE_ARN: 函数 ARN(在函数计算控制台右上角复制)
  • ACCESS_KEY_ID: 阿里云账号的 Access Key ID
  • SECRET_ACCESS_KEY:阿里云账号的 Access Key 密钥

环境变量

在“概览”页面,可以设置环境变量。推荐将 TZ 设置为 Asia/Shanghai,使得代码中读取到的时间为东八区时间(默认为 UTC 时间)。

调用方法

向部署后的 URL 发送 POST 请求,请求体格式为

{
    "source": <Your source code here>,
    "input": <Your standard input here>
}

安全性

阿里云函数计算每次运行都会创建一个新的容器,因此不需要担心运行危险的代码造成的环境破坏。但是要注意如果用户提交的代码访问公网会产生一定的费用,因此建议关闭函数计算的公网访问功能。

python-executor's People

Contributors

longern avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

python-executor's Issues

部署不成功哇

报错信息:
{
"errorMessage": "Expecting value: line 1 column 1 (char 0)",
"errorType": "JSONDecodeError",
"stackTrace": [
[
"File "/code/index.py"",
"line 65",
"in handler",
"request_obj: dict = json.loads(request_body)"
],
[
"File "/usr/local/lib/python3.6/json/init.py"",
"line 354",
"in loads",
"return _default_decoder.decode(s)"
],
[
"File "/usr/local/lib/python3.6/json/decoder.py"",
"line 339",
"in decode",
"obj, end = self.raw_decode(s, idx=_w(s, 0).end())"
],
[
"File "/usr/local/lib/python3.6/json/decoder.py"",
"line 357",
"in raw_decode",
"raise JSONDecodeError("Expecting value", s, err.value) from None"
]
]
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.