股票代碼查詢頁面


首先看頁面

引子

源於運營組同事和運維組同事的一點交互工作,運營同事經常會有配售、申購股票代碼查詢的動作,而這個生產查詢的接口只有運維同事有權限,所以此頁面的主要目的是打通生產到辦公網數據傳輸,交由運營同事自助查詢。

本例是一個最基本最簡單的Django案例

軟件版本介紹

  • OS RHEL6.5
  • Python 2.6.6
  • Django 1.6.8

Django框架

views.py

# _*_ encoding=utf-8 _*_

__author__ = 'weizhen'

from django.shortcuts import render_to_response

import time
import sys
import re
import os

reload(sys)
sys.setdefaultencoding('utf8')
base_dir = os.path.dirname(os.path.abspath(__file__))

def index(request):

    ret = {'result':''}
    result = ''

    today = time.strftime('%Y%m%d', time.localtime())
    codelist_file = '%s/%s.txt'%(basedir,today)
    
    f = open(codelist_file,'r')
    
    if request.method == 'POST':
        inp_codenum = request.POST.get('codenum', None)
        
        result = '%s 無干擾K線'%inp_codenum
        
        k_day_1 = '%s.day' % inp_codenum
        k_day_2 = '%s.Day' % inp_codenum
        
        
        k_day_1 = str(k_day_1)
        k_day_2 = str(k_day_1)
       
        for i in f:
            line = re.split(' ',i)[-1].strip('\n')

            if k_day_1 == line or k_day_2 == line:
                result = '%s 存在干擾K線,請郵件運維進行盤后處理'%inp_codenum
                break
    
    f.close()
    
    ret['result'] = result
    
    return render_to_response('selfcheck/index.html',ret)

 

selfcheck/index.html

<!DOCTYPE html>
<html lang="en">
<head class="ui semantic">
    <meta charset="UTF-8">
    <!-- <meta name="viewport" content="width=device-width, initial-scale=1.0"> -->
    <!-- //<meta http-equiv="X-UA-Compatible" content="ie=edge"> -->
    <title>查詢</title>
        <script src="/static/js/jquery-2.1.4.min.js"></script>
        <script src="/static/js/semantic.min.js"></script>
        <link rel="stylesheet" type="text/css" href="/static/css/semantic.min.css">
    <style>
    .topheader>a {
        padding-right: 15px;
        color: black;
        background-color: #fff;
        /* text-decoration:underline; */
        font-weight: bold;
    }
    a {
        text-decoration: underline;
        color: rgba(109, 99, 99, 0.76);
        font-size: 5px;
    }
    .bri {
        display: inline-block;

        right: 10px;
        width: 60px;
        height: 23px;

        color: #fff;
        background: #38f;
        line-height: 24px;
        font-size: 13px;
        text-align: center;
        overflow: hidden;
        /*border-bottom: 1px solid #38f;*/
        margin-left: 19px;
        margin-right: 2px;
    }
    </style>
</head>
<body>
    </br>
    </br>
    </br>
    </br>
    <div class="ui centered aligned grid container ">
            <div class="column" style="width: 270px;height: 129px;">
                <h2><font color="red">滬深市場重復代碼查詢</font></h2>
            </div>

        <div class="row">
            <form class="column" style="width:640px;" method="POST">
                <div class="ui fluid  input action">
                    <input type="text" name="codenum" placeholder="搜索股票代碼...">
                    <button class="medium ui blue button" onclick="document.forms['search'].submit();">搜索一下</button>
                </div>
            </form>
        </div>
        <div class="row">
            <form class="column" style="width:640px;">
                <div class="ui fluid  input action">
                       <font color="red"><b>{{ result }}</b></font>
                </div>
            </form>
        </div>
    </div>
</body>
</html>

 

附關於靜態頁面配置方法

STATIC_URL = '/static/'
STATICFILES_DIRS = (
    os.path.join(BASE_DIR,'static')
)
STATICFILES_DIRS = (
    BASE_DIR + '/static',
)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM