Skip to content

Commit d874996

Browse files
author
jiapan
committed
first commit
0 parents  commit d874996

15 files changed

+260
-0
lines changed

.gitignore

+142
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### JetBrains template
3+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
4+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
5+
6+
# User-specific stuff:
7+
.idea/**/workspace.xml
8+
.idea/**/tasks.xml
9+
.idea/dictionaries
10+
11+
# Sensitive or high-churn files:
12+
.idea/**/dataSources/
13+
.idea/**/dataSources.ids
14+
.idea/**/dataSources.xml
15+
.idea/**/dataSources.local.xml
16+
.idea/**/sqlDataSources.xml
17+
.idea/**/dynamic.xml
18+
.idea/**/uiDesigner.xml
19+
20+
# Gradle:
21+
.idea/**/gradle.xml
22+
.idea/**/libraries
23+
24+
# Mongo Explorer plugin:
25+
.idea/**/mongoSettings.xml
26+
27+
## File-based project format:
28+
*.iws
29+
30+
## Plugin-specific files:
31+
32+
# IntelliJ
33+
/out/
34+
35+
# mpeltonen/sbt-idea plugin
36+
.idea_modules/
37+
38+
# JIRA plugin
39+
atlassian-ide-plugin.xml
40+
41+
# Crashlytics plugin (for Android Studio and IntelliJ)
42+
com_crashlytics_export_strings.xml
43+
crashlytics.properties
44+
crashlytics-build.properties
45+
fabric.properties
46+
### Python template
47+
# Byte-compiled / optimized / DLL files
48+
__pycache__/
49+
*.py[cod]
50+
*$py.class
51+
52+
# C extensions
53+
*.so
54+
55+
# Distribution / packaging
56+
.Python
57+
env/
58+
build/
59+
develop-eggs/
60+
dist/
61+
downloads/
62+
eggs/
63+
.eggs/
64+
lib/
65+
lib64/
66+
parts/
67+
sdist/
68+
var/
69+
wheels/
70+
*.egg-info/
71+
.installed.cfg
72+
*.egg
73+
74+
# PyInstaller
75+
# Usually these files are written by a python script from a template
76+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
77+
*.manifest
78+
*.spec
79+
80+
# Installer logs
81+
pip-log.txt
82+
pip-delete-this-directory.txt
83+
84+
# Unit test / coverage reports
85+
htmlcov/
86+
.tox/
87+
.coverage
88+
.coverage.*
89+
.cache
90+
nosetests.xml
91+
coverage.xml
92+
*,cover
93+
.hypothesis/
94+
95+
# Translations
96+
*.mo
97+
*.pot
98+
99+
# Django stuff:
100+
*.log
101+
local_settings.py
102+
103+
# Flask stuff:
104+
instance/
105+
.webassets-cache
106+
107+
# Scrapy stuff:
108+
.scrapy
109+
110+
# Sphinx documentation
111+
docs/_build/
112+
113+
# PyBuilder
114+
target/
115+
116+
# Jupyter Notebook
117+
.ipynb_checkpoints
118+
119+
# pyenv
120+
.python-version
121+
122+
# celery beat schedule file
123+
celerybeat-schedule
124+
125+
# SageMath parsed files
126+
*.sage.py
127+
128+
# dotenv
129+
.env
130+
131+
# virtualenv
132+
.venv
133+
venv/
134+
ENV/
135+
136+
# Spyder project settings
137+
.spyderproject
138+
139+
# Rope project settings
140+
.ropeproject
141+
142+
.idea

Dockerfile

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM python:3.6
2+
3+
ADD sources.list /etc/apt/sources.list
4+
ADD pip.conf ~/.pip/pip.conf
5+
6+
# Add requirements.txt
7+
ADD requirements.txt /webapp/requirements.txt
8+
9+
# Install gunicorn Python web server
10+
RUN pip install gunicorn==19.9.0
11+
# Install app requirements
12+
RUN pip install -r /webapp/requirements.txt
13+
14+
# Create app directory
15+
ADD . /webapp
16+
17+
# Set the default directory for our environment
18+
ENV HOME /webapp
19+
WORKDIR /webapp
20+
21+
# Expose port 5000 for gunicorn
22+
EXPOSE 5000
23+
24+
ENTRYPOINT ["gunicorn", "-w", "2", "wsgi:app", "-b", "0.0.0.0:5000", "-n", "docker-flask", "--timeout", "45", "--max-requests", "10000"]

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
## 一个用来提供 svg 转 png 的服务

app/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from __future__ import unicode_literals, absolute_import

app/app.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from __future__ import unicode_literals, absolute_import
4+
5+
from flask import Flask
6+
from werkzeug.utils import import_string, find_modules
7+
8+
9+
extensions = [
10+
]
11+
12+
13+
def register_blueprints(root, app):
14+
for name in find_modules(root, recursive=True):
15+
mod = import_string(name)
16+
if hasattr(mod, 'bp'):
17+
app.register_blueprint(mod.bp)
18+
19+
20+
def create_app():
21+
app = Flask(__name__)
22+
23+
for extension_qualname in extensions:
24+
extension = import_string(extension_qualname)
25+
extension.init_app(app)
26+
27+
register_blueprints('app.web', app)
28+
return app

app/libs/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from __future__ import unicode_literals, absolute_import

app/models/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from __future__ import unicode_literals, absolute_import

app/web/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from __future__ import unicode_literals, absolute_import

app/web/api/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from __future__ import unicode_literals, absolute_import

app/web/views/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from __future__ import unicode_literals, absolute_import

app/web/views/index.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from __future__ import unicode_literals, absolute_import
4+
5+
import io
6+
import cairosvg
7+
8+
from flask import Blueprint, request, send_file
9+
10+
11+
12+
bp = Blueprint('home', __name__)
13+
14+
15+
@bp.route('/convert', methods = ['POST'])
16+
def index():
17+
data = request.data
18+
ret = cairosvg.svg2png(bytestring=data)
19+
return send_file(io.BytesIO(ret), mimetype='image/png')

pip.conf

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[global]
2+
index-url = http://mirrors.aliyun.com/pypi/simple/
3+
4+
[install]
5+
trusted-host=mirrors.aliyun.com

requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Flask==1.0.2
2+
cairosvg

sources.list

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Aliyun mirror
2+
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
3+
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
4+
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
5+
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
6+
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
7+
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
8+
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
9+
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
10+
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
11+
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse

wsgi.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from __future__ import unicode_literals, absolute_import
4+
5+
from app.app import create_app
6+
7+
app = create_app()
8+
9+
if __name__ == '__main__':
10+
app.run()

0 commit comments

Comments
 (0)