Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cao zihao 201831990221 pick most popular articles #50

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added NewColorStyle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified database.sqlite
Binary file not shown.
13 changes: 10 additions & 3 deletions service.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@


from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import or_
import os, uuid ,math, random
from flask import Flask, flash, request, redirect, url_for, session, jsonify, render_template, send_from_directory
from werkzeug.utils import secure_filename
from datetime import datetime, timedelta
from flask import Flask


basedir = os.path.abspath(os.path.dirname(__file__))
UPLOAD_FOLDER = basedir + '\static\pdf'
ALLOWED_EXTENSIONS = set(['pdf'])
Expand Down Expand Up @@ -317,7 +321,7 @@ def get_subject(subjectID):
hot_article.append(x)

return render_template('subject.html', url=url, subject_id=subject.id, articles=articles, hot_article=hot_article, Tool=Tool)

# ============================================================================================
# before request
# ============================================================================================
Expand Down Expand Up @@ -357,7 +361,10 @@ def before_request():
# ============================================================================================#
@app.route('/')
def index():
return render_template('io.html')
subjects = Subject.query.order_by(Subject.id.asc())
articles = Article.query.order_by(Article.metric.desc())[0:5]
totalart = Article.query.order_by(Article.time.desc())
return render_template('io.html', articles=articles, subjects=subjects, totalart=totalart, Tool=Tool)

@app.route('/test')
def test_one():
Expand All @@ -381,7 +388,7 @@ def find_subjects(subject, count):
find_subjects(subject, count + 1)

subjects = Subject.query.filter_by(pid='None').all()
out.write('{% extends "template.html" %}' + '\n')
out.write( '{% extends "template.html" %}' + '\n')
out.write('{% block content %}' + '\n')
for subject in subjects:
find_subjects(subject, 0)
Expand Down
95 changes: 24 additions & 71 deletions templates/io.html
Original file line number Diff line number Diff line change
@@ -1,76 +1,29 @@
{% extends "template.html" %}
{% block content %}
<body>
<body >

<div style="background-color:white;height:auto;width:30%;float:left;box-sizing: border-box;">
<h1 style="background-color: black;color:#FFFFFF;">Subjects</h1>
{% for subject in subjects %}
<a href="subject/{{subject.id}}" style="color:black">{{subject.name}}</a><br>
{%endfor%}
</div>
<div style="background-color:white;height:1423px;width:700px;float: left;box-sizing: border-box;">
<h1 style="background-color: black;color:white;">Top5 Articles</h1>

{% for article in articles %}
&emsp;<a href="article/{{ article.id }}" style="color:black">{{ article.title }}</a><br>
{% endfor %}



&emsp;
<h1 style="background-color:black;color:white;">All Articles</h1>
{% for article in totalart %}
&emsp;
<a href="article/{{article.id}}" style="color:black">{{article.title}}<span style="float: right;" style="color:black">{{article.time}}</span></a><br>
{%endfor%}
</div>

<a href="subject/1">Physical Sciences</a><br>
&emsp;
<a href="subject/8">Physics</a><br>
&emsp;
&emsp;
<a href="subject/11">Astronomy</a><br>
&emsp;
&emsp;
<a href="subject/12">Quantum Mechanics</a><br>
&emsp;
<a href="subject/9">Chemistry</a><br>
&emsp;
<a href="subject/10">Environmental Sciences</a><br>
<a href="subject/2">Social Sciences</a><br>
&emsp;
<a href="subject/13">Anthropology</a><br>
&emsp;
<a href="subject/14">Sustainability Science</a><br>
<a href="subject/3">Biological Sciences</a><br>
&emsp;
<a href="subject/15">Cell Biology</a><br>
&emsp;
&emsp;
<a href="subject/37">病理学</a><br>
&emsp;
<a href="subject/16">Genetics</a><br>
&emsp;
<a href="subject/17">Neuroscience</a><br>
&emsp;
<a href="subject/18">Plant Biology</a><br>
&emsp;
<a href="subject/19">Developmental Biology</a><br>
&emsp;
<a href="subject/20">System Biology</a><br>
&emsp;
<a href="subject/21">Biochemistry</a><br>
&emsp;
<a href="subject/22">Biophysics and Computational Biology</a><br>
<a href="subject/4">Computer Sciences</a><br>
&emsp;
<a href="subject/23">Machine Learning</a><br>
&emsp;
<a href="subject/24">Computational Biology</a><br>
&emsp;
<a href="subject/25">Computational Complexity</a><br>
&emsp;
<a href="subject/26">Computational Linguistics</a><br>
<a href="subject/5">Statistics</a><br>
&emsp;
<a href="subject/27">Applied Statistics</a><br>
&emsp;
<a href="subject/28">Mathematical Statistics</a><br>
<a href="subject/6">Mathematics</a><br>
&emsp;
<a href="subject/29">Graphy Theory</a><br>
&emsp;
<a href="subject/30">Number Theory</a><br>
<a href="subject/7">Medical Sciences</a><br>
&emsp;
<a href="subject/31">Breast Cancer</a><br>
&emsp;
<a href="subject/32">Ebola Virus</a><br>
&emsp;
<a href="subject/33">Epidemics</a><br>
&emsp;
<a href="subject/34">Dermatology General</a><br>
&emsp;
<a href="subject/35">Immunity</a><br>
&emsp;
<a href="subject/36">Obesity</a><br>
</body>
{% endblock %}
6 changes: 1 addition & 5 deletions templates/subject.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://use.fontawesome.com/releases/v5.0.8/js/all.js"></script>
<link href="style.css" rel="stylesheet">


</head>
<body>


<body >
CZH-Gaizka marked this conversation as resolved.
Show resolved Hide resolved
{% block head %}

<script>
Expand Down
6 changes: 5 additions & 1 deletion templates/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
<style>

footer{
background-color: #323a3a;
background-color: #0c7979;
color: #dadada;
padding-top: 2rem;
clear: both;

}
hr.light{
border-top: 1px solid #d5d5d5;
Expand All @@ -41,6 +43,7 @@
{% endblock %}
</head>
<body>
<div style="clear: both;">
<nav class="navbar navbar-expand-sm bg-dark navbar-dark">
<ul class="navbar-nav">
<li class="nav-item active">
Expand All @@ -61,6 +64,7 @@
</li>
</ul>
</nav>
</div>


<div style="font-size: 20px; line-height: 1.8; text-shadow: 0.3px 0.3px black; font-family: Times, serif;" class="col-sm-10 container">
Expand Down