Skip to content

Commit

Permalink
网站的基本前端框架和登录表单
Browse files Browse the repository at this point in the history
  • Loading branch information
kitakamiooi committed Nov 29, 2015
1 parent 8ca59f4 commit dc1e38d
Show file tree
Hide file tree
Showing 118 changed files with 392 additions and 2 deletions.
3 changes: 3 additions & 0 deletions base/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@

# 代理服务器
proxy = os.environ.get('OOI_PROXY', None)

# Cookie的secret key
secret_key = os.environ.get('OOI_SECRET_KEY', 'You Must Set A Secret Key!').encode()
28 changes: 28 additions & 0 deletions handlers/frontend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import aiohttp_jinja2
from aiohttp_session import get_session


class FrontEndHandler:

@aiohttp_jinja2.template('form.html')
async def form(self, request):
session = await get_session(request)
if 'mode' in session:
mode = session['mode']
else:
session['mode'] = 1
mode = 1

return {'mode': mode}

def normal(self):
pass

def kcv(self):
pass

def poi(self):
pass

def logout(self):
pass
21 changes: 20 additions & 1 deletion ooi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@

import argparse
import asyncio
import os

import jinja2
from aiohttp import web
import aiohttp_jinja2
from aiohttp_session import session_middleware
from aiohttp_session.cookie_storage import EncryptedCookieStorage

from base import config
from handlers.frontend import FrontEndHandler
from handlers.service import ServiceHandler

parser = argparse.ArgumentParser(description='Online Objects Integration version 3.0')
Expand All @@ -12,6 +20,8 @@
parser.add_argument('-p', '--port', type=int, default=9999,
help='The port of OOI server')

base_dir = os.path.dirname(os.path.abspath(__file__))


def main():
"""OOI运行主函数。
Expand All @@ -28,14 +38,23 @@ def main():
loop = asyncio.get_event_loop()

# 初始化请求处理器
frontend = FrontEndHandler()
service = ServiceHandler()

# 定义会话中间件
middlewares = [session_middleware(EncryptedCookieStorage(config.secret_key)), ]

# 初始化应用
app = web.Application(loop=loop)
app = web.Application(middlewares=middlewares, loop=loop)

# 定义Jinja2模板位置
aiohttp_jinja2.setup(app, loader=jinja2.FileSystemLoader(os.path.join(base_dir, 'templates')))

# 给应用添加路由
app.router.add_route('GET', '/', frontend.form)
app.router.add_route('POST', '/service/osapi', service.get_osapi)
app.router.add_route('POST', '/service/flash', service.get_flash)
app.router.add_static('/static', os.path.join(base_dir, 'static'))
app_handlers = app.make_handler()

# 启动OOI服务器
Expand Down
13 changes: 12 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
aiohttp==0.18.4
aiohttp==0.19.0
aiohttp_jinja2==0.6.2
aiohttp_session==0.3.0
cffi==1.3.1
chardet==2.3.0
cryptography==1.1.1
idna==2.0
Jinja2==2.8
MarkupSafe==0.23
pyasn1==0.1.9
pycparser==2.14
six==1.10.0
2 changes: 2 additions & 0 deletions static/css/components/accordion.almost-flat.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions static/css/components/accordion.gradient.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions static/css/components/accordion.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions static/css/components/autocomplete.almost-flat.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions static/css/components/autocomplete.gradient.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions static/css/components/autocomplete.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions static/css/components/datepicker.almost-flat.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions static/css/components/datepicker.gradient.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions static/css/components/datepicker.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions static/css/components/dotnav.almost-flat.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions static/css/components/dotnav.gradient.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions static/css/components/dotnav.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions static/css/components/form-advanced.almost-flat.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions static/css/components/form-advanced.gradient.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions static/css/components/form-advanced.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions static/css/components/form-file.almost-flat.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions static/css/components/form-file.gradient.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions static/css/components/form-file.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions static/css/components/form-password.almost-flat.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions static/css/components/form-password.gradient.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions static/css/components/form-password.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit dc1e38d

Please sign in to comment.