Skip to content

Commit 2258f55

Browse files
committed
增加示例工程
1 parent b934ca6 commit 2258f55

31 files changed

+479
-0
lines changed

server/projects/ide/VmExample/.config

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"expendKeys":[
3+
"/src/html",
4+
"/src/shell",
5+
"/src/c#",
6+
"/src/js",
7+
"/src/css",
8+
"/include",
9+
"/src/c",
10+
"/src/vue/components",
11+
"/src/python/utils",
12+
"/",
13+
"/scripts",
14+
"/src/vue",
15+
"/src/python",
16+
"/src"
17+
],
18+
"lastAccessTime":1661222250.1999269,
19+
"openList":[
20+
"/src/python/main.py",
21+
"/src/python/utils/calc.py",
22+
"/src/python/time_echo.py"
23+
],
24+
"selectFilePath":"/src/python/main.py",
25+
"type":"python"
26+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Python-Web-IDE
2+
-----------
3+
> 一个简易的在线Python的IDE
4+
> 基于Vue3 + Python3.10 + Tornado6.1实现
5+
> 前后端分离
6+
7+
## 功能说明
8+
- 支持工程、文件、文件夹的增删查改
9+
- 支持Python代码基本补全
10+
- 支持Python代码(GUI不支持)运行管理和输出
11+
- 支持Markdown文件的编辑和预览
12+
13+
## 更新说明
14+
- 基于Vue3+Python3.10的全新实现
15+
- 引入markdown编辑器
16+
- 引入图标vscode-icons
17+
- 更改编辑器主题
18+
19+
## 编译和运行
20+
### 环境
21+
- Node: 16.13.2
22+
- Npm: 8.1.2
23+
- Python: 3.10
24+
- Tornado: 6.1
25+
26+
### 前端
27+
```bash
28+
# 安装依赖
29+
npm install 或者 yarn install
30+
31+
# 开发运行(默认端口是8080)
32+
npm run serve
33+
34+
# 打包编译(默认打包的路径在dist目录,后端程序已经配置从该目录加载资源)
35+
npm run build
36+
```
37+
38+
### 后端
39+
```bash
40+
# 假定已经安装好Python环境(建议使用虚拟Python环境并激活)
41+
42+
# 进入后端目录
43+
cd server
44+
45+
# 安装依赖
46+
pip install -r requirements.txt
47+
48+
# 运行(运行端口为10086)指定端口可以使用参数 --port=10010
49+
# 如果前端页面是独立运行的,不可指定后端端口(除非修改前端代码)
50+
python server.py
51+
52+
# 访问 (工程保存在projects/ide里面)
53+
# 开发运行前端的情况: localhost:8080
54+
# 打包好前端的情况: localhost:10086
55+
```
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env python3
2+
# Software License Agreement (BSD License)
3+
#
4+
# Copyright (c) 2022, Vinman, Inc.
5+
# All rights reserved.
6+
#
7+
# Author: Vinman <vinman.cub@gmail.com>
8+
9+
import os
10+
from setuptools import setup, find_packages
11+
12+
setup(
13+
name='pytest',
14+
version='1.0.0',
15+
author='Vinman',
16+
description='just for test',
17+
packages=find_packages(),
18+
author_email='vinman.cub@gmail.com',
19+
install_requires=[],
20+
long_description='just for test',
21+
license='BSD',
22+
zip_safe=False
23+
)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
3+
namespace csharp_demo
4+
{
5+
class Program
6+
{
7+
static void Main(string[] args)
8+
{
9+
Console.WriteLine("Hello World");
10+
}
11+
}
12+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
CC=gcc
3+
CFLAGS=-c -Wall -g
4+
5+
OBJS=main.o utils.o
6+
7+
main:$(OBJS)
8+
$(CC $^ -o main
9+
10+
%.o:%.cpp
11+
$(CC) $^ $(CFLAGS) -o $@
12+
clean:
13+
rm *.o main
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
# Software License Agreement (MIT License)
3+
#
4+
# Copyright (c) 2022, Vinman, Inc.
5+
# All rights reserved.
6+
#
7+
# Author: Vinman <vinman.cub@gmail.com>
8+
*/
9+
10+
#include <stdio.h>
11+
#include "utils.hpp"
12+
13+
int main(int argc, char *argv[]) {
14+
Utils util;
15+
int a = 100;
16+
int b = 36;
17+
printf("%d + %d = %d\n", util.add(a, b));
18+
printf("%d - %d = %d\n", util.sub(a, b));
19+
return 0;
20+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
# Software License Agreement (MIT License)
3+
#
4+
# Copyright (c) 2022, Vinman, Inc.
5+
# All rights reserved.
6+
#
7+
# Author: Vinman <vinman.cub@gmail.com>
8+
*/
9+
10+
#include "utils.hpp"
11+
12+
int Utils::add(int a, int b) {
13+
return a + b;
14+
}
15+
16+
int Utils::sub(int a, int b) {
17+
return a - b;
18+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
# Software License Agreement (MIT License)
3+
#
4+
# Copyright (c) 2022, Vinman, Inc.
5+
# All rights reserved.
6+
#
7+
# Author: Vinman <vinman.cub@gmail.com>
8+
*/
9+
10+
#ifndef __UTILS_H_
11+
#define __UTILS_H_
12+
13+
class Utils {
14+
public:
15+
int add(int a, int b);
16+
int sub(int a, int b);
17+
};
18+
19+
20+
#endif // __UTILS_H_
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
CC=gcc
3+
CFLAGS=-c -Wall -g
4+
5+
OBJS=main.o hello.o
6+
7+
ALL: main
8+
9+
main:$(OBJS)
10+
$(CC $^ -o main
11+
12+
%.o:%.c
13+
$(CC) $^ $(CFLAGS) -o $@
14+
clean:
15+
rm *.o main
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
# Software License Agreement (MIT License)
3+
#
4+
# Copyright (c) 2022, Vinman, Inc.
5+
# All rights reserved.
6+
#
7+
# Author: Vinman <vinman.cub@gmail.com>
8+
*/
9+
10+
#include "hello.h"
11+
12+
int add(int a, int b) {
13+
return a + b;
14+
}
15+
16+
int sub(int a, int b) {
17+
return a - b;
18+
}
19+
20+
int main(int argc, char *argv[]) {
21+
return 0;
22+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
# Software License Agreement (MIT License)
3+
#
4+
# Copyright (c) 2022, Vinman, Inc.
5+
# All rights reserved.
6+
#
7+
# Author: Vinman <vinman.cub@gmail.com>
8+
*/
9+
10+
#ifndef __HELLO_H_
11+
#define __HELLO_H_
12+
13+
int add(int a, int b);
14+
int sub(int a, int b);
15+
16+
#endif // __HELLO_H_
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
# Software License Agreement (MIT License)
3+
#
4+
# Copyright (c) 2022, Vinman, Inc.
5+
# All rights reserved.
6+
#
7+
# Author: Vinman <vinman.cub@gmail.com>
8+
*/
9+
10+
#include <stdio.h>
11+
#include "hello.h"
12+
13+
int main(int argc, char *argv[]) {
14+
int a = 100;
15+
int b = 36;
16+
printf("%d + %d = %d\n", add(a, b));
17+
printf("%d - %d = %d\n", sub(a, b));
18+
return 0;
19+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.float-left {
2+
float: left;
3+
}
4+
.float-right {
5+
float: right;
6+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
body {
2+
width: 100%;
3+
height: 100%;
4+
}

server/projects/ide/VmExample/src/css/utils.sass

Whitespace-only changes.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<html>
2+
<head>
3+
<title>HTML DEMO</title>
4+
</head>
5+
<body>
6+
<div>
7+
<p>Hello, HTML!</p>
8+
</div>
9+
</body>
10+
</html>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import axios from "axios";
2+
3+
function get(baseURL, success_callback, url) {
4+
axios.get('/corstests/get_csrf_token_with_cookie/', {
5+
baseURL: baseURL ? baseURL : 'http://localhost:8000',
6+
withCredentials: true
7+
}).then(res => {
8+
if (res.status == 200) {
9+
let regex = /.*csrftoken=([^;.]*).*$/; // 用于从cookie中匹配 csrftoken值
10+
this.csrftoken = document.cookie.match(regex) === null ? null : document.cookie.match(regex)[1];
11+
if (success_callback) {
12+
success_callback(url, baseURL)
13+
}
14+
}
15+
else {
16+
}
17+
})
18+
.catch(function (error) {
19+
ElMessage({
20+
message: `get token failure, error=${error}`,
21+
type: 'failure',
22+
});
23+
});
24+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env python3
2+
# Software License Agreement (BSD License)
3+
#
4+
# Copyright (c) 2022, Vinman, Inc.
5+
# All rights reserved.
6+
#
7+
# Author: Vinman <vinman.cub@gmail.com>
8+
9+
import time
10+
import random
11+
from utils.calc import add, sub
12+
13+
14+
if __name__ == '__main__':
15+
a = 99
16+
b = 25
17+
print('{} + {} = {}'.format(a, b, add(a, b)))
18+
print('{} - {} = {}'.format(a, b, sub(a, b)))
19+
20+
ret = 0
21+
22+
while True:
23+
a = ret
24+
b = random.randint(1, 100)
25+
ret += b
26+
print('{} + {} = {}'.format(a, b, ret))
27+
time.sleep(1)
28+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import time
2+
import datetime
3+
4+
5+
while True:
6+
print(datetime.datetime.now())
7+
time.sleep(1)

server/projects/ide/VmExample/src/python/utils/__init__.py

Whitespace-only changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env python3
2+
# Software License Agreement (BSD License)
3+
#
4+
# Copyright (c) 2022, Vinman, Inc.
5+
# All rights reserved.
6+
#
7+
# Author: Vinman <vinman.cub@gmail.com>
8+
9+
def add(a, b):
10+
return a + b
11+
12+
13+
def sub(a, b):
14+
return a - b
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
echo `date`

0 commit comments

Comments
 (0)