예제 #1
0
파일: markdo.py 프로젝트: nitipit/markdo
#!/usr/bin/env python

from appkit.api.v0_2_8 import App
from flask import render_template, request
import os
import sys
import codecs

app = App(__name__)

try:
    file_name = sys.argv[1]
    if not os.path.exists(file_name):
        open(file_name, 'w').close()
except:
    file_name = None

app.file_name = file_name
print(app.file_name)


@app.route('/')
def index():
    markdown = None
    if app.file_name is not None:
        markdown = codecs.open(file_name, 'r', 'utf-8').read()
    return render_template(
            '/ui.html',
            file_name=app.file_name,
            text=markdown)
예제 #2
0
파일: restr.py 프로젝트: nitipit/restr
#!/usr/bin/env python

from appkit.api.v0_2_8 import App
from flask import render_template, request
import os
import sys
from docutils.core import publish_parts


app = App(__name__)

try:
    file_name = sys.argv[1]
    if not os.path.exists(file_name):
        open(file_name, 'w').close()
except:
    file_name = None

app.file_name = file_name


@app.route('/')
def index():
    text = None
    if app.file_name is not None:
        text = open(file_name).read()
    return render_template('/ui.html', file_name=app.file_name, text=text)


@app.route('/rst2html/', methods=['POST', ])
def rst2html():