Browse Source

Find way to display articles content from API

Carlos Hernandez 3 years ago
parent
commit
8604219fd5

+ 141
- 0
.gitignore View File

@@ -0,0 +1,141 @@
1
+# Local
2
+.vscode
3
+
4
+# Byte-compiled / optimized / DLL files
5
+__pycache__/
6
+*.py[cod]
7
+*$py.class
8
+
9
+# C extensions
10
+*.so
11
+
12
+# Distribution / packaging
13
+.Python
14
+build/
15
+develop-eggs/
16
+dist/
17
+downloads/
18
+eggs/
19
+.eggs/
20
+lib/
21
+lib64/
22
+parts/
23
+sdist/
24
+var/
25
+wheels/
26
+share/python-wheels/
27
+*.egg-info/
28
+.installed.cfg
29
+*.egg
30
+MANIFEST
31
+
32
+# PyInstaller
33
+#  Usually these files are written by a python script from a template
34
+#  before PyInstaller builds the exe, so as to inject date/other infos into it.
35
+*.manifest
36
+*.spec
37
+
38
+# Installer logs
39
+pip-log.txt
40
+pip-delete-this-directory.txt
41
+
42
+# Unit test / coverage reports
43
+htmlcov/
44
+.tox/
45
+.nox/
46
+.coverage
47
+.coverage.*
48
+.cache
49
+nosetests.xml
50
+coverage.xml
51
+*.cover
52
+*.py,cover
53
+.hypothesis/
54
+.pytest_cache/
55
+cover/
56
+
57
+# Translations
58
+*.mo
59
+*.pot
60
+
61
+# Django stuff:
62
+*.log
63
+local_settings.py
64
+db.sqlite3
65
+db.sqlite3-journal
66
+
67
+# Flask stuff:
68
+instance/
69
+.webassets-cache
70
+
71
+# Scrapy stuff:
72
+.scrapy
73
+
74
+# Sphinx documentation
75
+docs/_build/
76
+
77
+# PyBuilder
78
+.pybuilder/
79
+target/
80
+
81
+# Jupyter Notebook
82
+.ipynb_checkpoints
83
+
84
+# IPython
85
+profile_default/
86
+ipython_config.py
87
+
88
+# pyenv
89
+#   For a library or package, you might want to ignore these files since the code is
90
+#   intended to run in multiple environments; otherwise, check them in:
91
+# .python-version
92
+
93
+# pipenv
94
+#   According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
95
+#   However, in case of collaboration, if having platform-specific dependencies or dependencies
96
+#   having no cross-platform support, pipenv may install dependencies that don't work, or not
97
+#   install all needed dependencies.
98
+#Pipfile.lock
99
+
100
+# PEP 582; used by e.g. github.com/David-OConnor/pyflow
101
+__pypackages__/
102
+
103
+# Celery stuff
104
+celerybeat-schedule
105
+celerybeat.pid
106
+
107
+# SageMath parsed files
108
+*.sage.py
109
+
110
+# Environments
111
+.env
112
+.venv
113
+env/
114
+venv/
115
+ENV/
116
+env.bak/
117
+venv.bak/
118
+
119
+# Spyder project settings
120
+.spyderproject
121
+.spyproject
122
+
123
+# Rope project settings
124
+.ropeproject
125
+
126
+# mkdocs documentation
127
+/site
128
+
129
+# mypy
130
+.mypy_cache/
131
+.dmypy.json
132
+dmypy.json
133
+
134
+# Pyre type checker
135
+.pyre/
136
+
137
+# pytype static type analyzer
138
+.pytype/
139
+
140
+# Cython debug symbols
141
+cython_debug/

+ 4
- 0
Files-API/articles/article_1.txt View File

@@ -0,0 +1,4 @@
1
+Utilitatis causa amicitia est quaesita.
2
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Collatio igitur ista te nihil iuvat. Honesta oratio, Socratica, Platonis etiam. Primum in nostrane potestate est, quid meminerimus? Duo Reges: constructio interrete. Quid, si etiam iucunda memoria est praeteritorum malorum? Si quidem, inquit, tollerem, sed relinquo. An nisi populari fama?
3
+
4
+Quamquam id quidem licebit iis existimare, qui legerint. Summum a vobis bonum voluptas dicitur. At hoc in eo M. Refert tamen, quo modo. Quid sequatur, quid repugnet, vident. Iam id ipsum absurdum, maximum malum neglegi.

+ 13
- 0
Files-API/articles/article_2.txt View File

@@ -0,0 +1,13 @@
1
+Aeque enim contingit omnibus fidibus, ut incontentae sint.
2
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quae cum ita sint, effectum est nihil esse malum, quod turpe non sit. Itaque nostrum est-quod nostrum dico, artis est-ad ea principia, quae accepimus. Quod totum contra est. Duo Reges: constructio interrete. Atqui iste locus est, Piso, tibi etiam atque etiam confirmandus, inquam; Quamvis enim depravatae non sint, pravae tamen esse possunt. Duarum enim vitarum nobis erunt instituta capienda.
3
+
4
+Non igitur de improbo, sed de callido improbo quaerimus, qualis Q. Audio equidem philosophi vocem, Epicure, sed quid tibi dicendum sit oblitus es. Ex ea difficultate illae fallaciloquae, ut ait Accius, malitiae natae sunt. At multis malis affectus. Nam quibus rebus efficiuntur voluptates, eae non sunt in potestate sapientis. Quis est tam dissimile homini. Ut proverbia non nulla veriora sint quam vestra dogmata. Si quicquam extra virtutem habeatur in bonis. Sed plane dicit quod intellegit. Paulum, cum regem Persem captum adduceret, eodem flumine invectio?
5
+
6
+Qui ita affectus, beatum esse numquam probabis; Sed nimis multa. Nam prius a se poterit quisque discedere quam appetitum earum rerum, quae sibi conducant, amittere. Familiares nostros, credo, Sironem dicis et Philodemum, cum optimos viros, tum homines doctissimos. Quod iam a me expectare noli. Quid ergo?
7
+
8
+Eademne, quae restincta siti? Ita relinquet duas, de quibus etiam atque etiam consideret. Illa videamus, quae a te de amicitia dicta sunt. Eaedem res maneant alio modo. Quid ergo attinet gloriose loqui, nisi constanter loquare? Prioris generis est docilitas, memoria; Portenta haec esse dicit, neque ea ratione ullo modo posse vivi; Beatum, inquit. Bestiarum vero nullum iudicium puto.
9
+
10
+Quem Tiberina descensio festo illo die tanto gaudio affecit, quanto L. Quorum sine causa fieri nihil putandum est. Tria genera bonorum; Nunc dicam de voluptate, nihil scilicet novi, ea tamen, quae te ipsum probaturum esse confidam. Illud dico, ea, quae dicat, praeclare inter se cohaerere. Fortemne possumus dicere eundem illum Torquatum? Hoc tu nunc in illo probas. Cur post Tarentum ad Archytam?
11
+
12
+Indicant pueri, in quibus ut in speculis natura cernitur.
13
+Sed tamen est aliquid, quod nobis non liceat, liceat illis. Virtutis, magnitudinis animi, patientiae, fortitudinis fomentis dolor mitigari solet. Piso igitur hoc modo, vir optimus tuique, ut scis, amantissimus. Non prorsus, inquit, omnisque, qui sine dolore sint, in voluptate, et ea quidem summa, esse dico. Potius inflammat, ut coercendi magis quam dedocendi esse videantur. Virtutis, magnitudinis animi, patientiae, fortitudinis fomentis dolor mitigari solet. Quae fere omnia appellantur uno ingenii nomine, easque virtutes qui habent, ingeniosi vocantur. Nec enim, dum metuit, iustus est, et certe, si metuere destiterit, non erit;

+ 21
- 0
Files-API/articles/article_3.txt View File

@@ -0,0 +1,21 @@
1
+Quod equidem non reprehendo;
2
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quibus natura iure responderit non esse verum aliunde finem beate vivendi, a se principia rei gerendae peti; Quae enim adhuc protulisti, popularia sunt, ego autem a te elegantiora desidero. Duo Reges: constructio interrete. Tum Lucius: Mihi vero ista valde probata sunt, quod item fratri puto. Bestiarum vero nullum iudicium puto. Nihil enim iam habes, quod ad corpus referas; Deinde prima illa, quae in congressu solemus: Quid tu, inquit, huc? Et homini, qui ceteris animantibus plurimum praestat, praecipue a natura nihil datum esse dicemus?
3
+
4
+Iam id ipsum absurdum, maximum malum neglegi. Quod ea non occurrentia fingunt, vincunt Aristonem; Atqui perspicuum est hominem e corpore animoque constare, cum primae sint animi partes, secundae corporis. Fieri, inquam, Triari, nullo pacto potest, ut non dicas, quid non probes eius, a quo dissentias. Equidem e Cn. An dubium est, quin virtus ita maximam partem optineat in rebus humanis, ut reliquas obruat?
5
+
6
+Quis istum dolorem timet?
7
+Summus dolor plures dies manere non potest? Dicet pro me ipsa virtus nec dubitabit isti vestro beato M. Tubulum fuisse, qua illum, cuius is condemnatus est rogatione, P. Quod si ita sit, cur opera philosophiae sit danda nescio.
8
+
9
+Ex eorum enim scriptis et institutis cum omnis doctrina liberalis, omnis historia.
10
+Quod si ita est, sequitur id ipsum, quod te velle video, omnes semper beatos esse sapientes. Cum enim fertur quasi torrens oratio, quamvis multa cuiusque modi rapiat, nihil tamen teneas, nihil apprehendas, nusquam orationem rapidam coerceas. Ita redarguitur ipse a sese, convincunturque scripta eius probitate ipsius ac moribus. At quanta conantur! Mundum hunc omnem oppidum esse nostrum! Incendi igitur eos, qui audiunt, vides. Vide, ne magis, inquam, tuum fuerit, cum re idem tibi, quod mihi, videretur, non nova te rebus nomina inponere. Qui-vere falsone, quaerere mittimus-dicitur oculis se privasse; Si ista mala sunt, in quae potest incidere sapiens, sapientem esse non esse ad beate vivendum satis. At vero si ad vitem sensus accesserit, ut appetitum quendam habeat et per se ipsa moveatur, quid facturam putas?
11
+
12
+Quem si tenueris, non modo meum Ciceronem, sed etiam me ipsum abducas licebit.
13
+Stulti autem malorum memoria torquentur, sapientes bona praeterita grata recordatione renovata delectant.
14
+Esse enim quam vellet iniquus iustus poterat inpune.
15
+Quae autem natura suae primae institutionis oblita est?
16
+Verum tamen cum de rebus grandioribus dicas, ipsae res verba rapiunt;
17
+Hoc est non modo cor non habere, sed ne palatum quidem.
18
+Voluptatem cum summum bonum diceret, primum in eo ipso parum vidit, deinde hoc quoque alienum; Sed tu istuc dixti bene Latine, parum plane. Nam haec ipsa mihi erunt in promptu, quae modo audivi, nec ante aggrediar, quam te ab istis, quos dicis, instructum videro. Fatebuntur Stoici haec omnia dicta esse praeclare, neque eam causam Zenoni desciscendi fuisse. Non autem hoc: igitur ne illud quidem. Ratio quidem vestra sic cogit. Cum audissem Antiochum, Brute, ut solebam, cum M. An quod ita callida est, ut optime possit architectari voluptates?
19
+
20
+Idemne, quod iucunde?
21
+Haec mihi videtur delicatior, ut ita dicam, molliorque ratio, quam virtutis vis gravitasque postulat. Sed quoniam et advesperascit et mihi ad villam revertendum est, nunc quidem hactenus; Cuius ad naturam apta ratio vera illa et summa lex a philosophis dicitur. Neque solum ea communia, verum etiam paria esse dixerunt. Sed nunc, quod agimus; A mene tu?

+ 1
- 0
Files-API/articles/article_4.txt View File

@@ -0,0 +1 @@
1
+Hello world!

+ 32
- 0
Files-API/files_api.py View File

@@ -0,0 +1,32 @@
1
+import os
2
+from flask import Flask, send_from_directory, jsonify, current_app
3
+from flask_cors import CORS, cross_origin
4
+
5
+
6
+app = Flask(__name__, static_url_path='')
7
+app.config["SECRET_KEY"] = "f82abccd93a28b6cdda4525c9afa7a30"
8
+app.config["CORS_HEADERS"] = "Content-Type"
9
+
10
+cors = CORS(app, resources={r"/articles": {"origins": "http://localhost:5500"}})
11
+
12
+
13
+@app.route("/articles/<path:article>")
14
+@cross_origin(origin="localhost", headers=["Content-Type", "Authorization"])
15
+def send_text_file(article):
16
+    return send_from_directory(directory="articles", path=article)
17
+
18
+
19
+@app.route("/articles")
20
+@cross_origin(origin="localhost", headers=["Content-Type", "Authorization"])
21
+def list_files():
22
+    files = list()
23
+    for filename in os.listdir(os.path.join(current_app.root_path, "articles")):
24
+        path = os.path.join(current_app.root_path, "articles", filename)
25
+        if os.path.isfile(path):
26
+            files.append(filename)
27
+    return jsonify(files)
28
+
29
+
30
+if __name__ == "__main__":
31
+    app.run()
32
+

+ 26
- 0
Files-API/requirements.txt View File

@@ -0,0 +1,26 @@
1
+backcall==0.2.0
2
+click==8.0.3
3
+decorator==5.1.0
4
+flake8==4.0.1
5
+Flask==2.0.2
6
+Flask-Cors==3.0.10
7
+ipython==7.29.0
8
+itsdangerous==2.0.1
9
+jedi==0.18.0
10
+Jinja2==3.0.2
11
+MarkupSafe==2.0.1
12
+matplotlib-inline==0.1.3
13
+mccabe==0.6.1
14
+parso==0.8.2
15
+pexpect==4.8.0
16
+pickleshare==0.7.5
17
+pkg_resources==0.0.0
18
+prompt-toolkit==3.0.21
19
+ptyprocess==0.7.0
20
+pycodestyle==2.8.0
21
+pyflakes==2.4.0
22
+Pygments==2.10.0
23
+six==1.16.0
24
+traitlets==5.1.1
25
+wcwidth==0.2.5
26
+Werkzeug==2.0.2

+ 177
- 0
app_template/www/articles.html View File

@@ -0,0 +1,177 @@
1
+
2
+<!DOCTYPE html>
3
+<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
4
+<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
5
+<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
6
+<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
7
+	<head>
8
+		<meta charset="utf-8">
9
+		<meta http-equiv="X-UA-Compatible" content="IE=edge">
10
+		<title>dato.pr</title>
11
+		<meta name="viewport" content="width=device-width, initial-scale=1">
12
+		<meta name="description" content="No" />
13
+
14
+			<!-- Facebook and Twitter integration -->
15
+		<meta property="og:title" content=""/>
16
+		<meta property="og:image" content=""/>
17
+		<meta property="og:url" content=""/>
18
+		<meta property="og:site_name" content=""/>
19
+		<meta property="og:description" content=""/>
20
+		<meta name="twitter:title" content="" />
21
+		<meta name="twitter:image" content="" />
22
+		<meta name="twitter:url" content="" />
23
+		<meta name="twitter:card" content="" />
24
+
25
+		<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
26
+		<link rel="shortcut icon" href="favicon.ico">
27
+
28
+		<link href="https://fonts.googleapis.com/css?family=Inconsolata:400,700" rel="stylesheet">
29
+
30
+		<!-- Custom css -->
31
+		<link rel="stylesheet" href="css/main.css">
32
+
33
+		<!-- Animate.css -->
34
+		<link rel="stylesheet" href="css/animate.css">
35
+		<!-- Icomoon Icon Fonts-->
36
+		<link rel="stylesheet" href="css/icomoon.css">
37
+		<!-- Simple Line Icons -->
38
+		<link rel="stylesheet" href="css/simple-line-icons.css">
39
+		<!-- Bootstrap  -->
40
+		<link rel="stylesheet" href="css/bootstrap.css">
41
+		<!-- Style -->
42
+		<link rel="stylesheet" href="css/style.css">
43
+
44
+
45
+		<!-- Modernizr JS -->
46
+		<script src="js/modernizr-2.6.2.min.js"></script>
47
+		<!-- FOR IE9 below -->
48
+		<!--[if lt IE 9]>
49
+		<script src="js/respond.min.js"></script>
50
+		<![endif]-->
51
+
52
+		<!-- Custom JS -->
53
+		<script src="sortposts.js"></script>
54
+
55
+		<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
56
+		<script>
57
+			var articles;
58
+			axios.get(`http://localhost:5000/articles`)
59
+					.then(response => {
60
+						articles = response.data;
61
+
62
+						for (element of articles) {
63
+							axios.get(`http://localhost:5000/articles/${element}`)
64
+								.then(response => {
65
+									let articlesHeading = document.querySelector("#articles-heading");
66
+									let articleElm = document.createElement("pre");
67
+									articleElm.textContent = response.data;
68
+									articlesHeading.appendChild(articleElm);
69
+								})
70
+								.catch(error => console.error(error));
71
+						}
72
+					})
73
+					.catch(error => console.error(error));
74
+
75
+		</script>
76
+	</head>
77
+	<body>
78
+	<header role="banner" id="fh5co-header">
79
+		<div class="fluid-container">
80
+			<nav class="navbar navbar-default navbar-fixed-top js-fullheight">
81
+				<div id="navbar" class="navbar-collapse js-fullheight">
82
+					<ul class="nav navbar-nav navbar-left">
83
+						<li class="active"><a href="#" data-nav-section="home"><span>Home</span></a></li>
84
+						<li><a href="#" data-nav-section="services"><span>Services</span></a></li>
85
+					</ul>
86
+				</div>
87
+			</nav>
88
+	  </div>
89
+	</header>
90
+
91
+	<section id="fh5co-home" data-section="home" style="background-image: url(images/project-5.jpg);">
92
+		<div class="gradient"></div>
93
+		<div class="container">
94
+			<div class="text-wrap">
95
+				<div class="text-inner">
96
+					<div class="row">
97
+						<div class="col-md-8 col-md-offset-2 text-center">
98
+							<h1 style="color :white;" class="to-animate">dato.pr</h1>
99
+							<h2 style="color :white;" class="to-animate">"Estudiando lo ambiguo e investigando lo desconocido."</h2>
100
+						</div>
101
+					</div>
102
+				</div>
103
+			</div>
104
+		</div>
105
+	</section>
106
+
107
+	<section id="fh5co-services" data-section="services">
108
+		<div class="fh5co-services">
109
+			<div class="container">
110
+				<div class="row">
111
+					<div class="col-md-12 section-heading text-center">
112
+						<h2 class="to-animate">Articles</h2>
113
+					</div>
114
+				</div>
115
+				<div class="row">
116
+					<div class="core-features">
117
+						<div class="grid2">
118
+							<div id="rows-parent" class="core-f">
119
+								<div class="row" id="articles-row">
120
+									<div class="col-md-12">
121
+										<div class="core">
122
+											<i class="icon-columns to-animate-2"></i>
123
+											<div class="fh5co-post to-animate">
124
+												<!-- <h3 async onload="fetchArticle();">Articles</h3> -->
125
+												<h3 id="articles-heading">Articles</h3>
126
+											</div>
127
+										</div>
128
+									</div>
129
+								</div>
130
+							</div>
131
+						</div>
132
+					</div>
133
+				</div>
134
+				<div id="fh5co-counter-section" class="fh5co-counters">
135
+					<div class="container">
136
+						<div class="row to-animate">
137
+							<div class="col-md-3 text-center">
138
+								<span class="fh5co-counter js-counter" data-from="0" data-to="3452" data-speed="5000" data-refresh-interval="50"></span>
139
+								<span class="fh5co-counter-label">Tazas de Café Consumidas</span>
140
+							</div>
141
+							<div class="col-md-3 text-center">
142
+								<span class="fh5co-counter js-counter" data-from="0" data-to="234" data-speed="5000" data-refresh-interval="50"></span>
143
+								<span class="fh5co-counter-label">Días sin Luz</span>
144
+							</div>
145
+							<div class="col-md-3 text-center">
146
+								<span class="fh5co-counter js-counter" data-from="0" data-to="6542" data-speed="5000" data-refresh-interval="50"></span>
147
+								<span class="fh5co-counter-label">Cosas que Hacer</span>
148
+							</div>
149
+							<div class="col-md-3 text-center">
150
+								<span class="fh5co-counter js-counter" data-from="0" data-to="0" data-speed="5000" data-refresh-interval="50"></span>
151
+								<span class="fh5co-counter-label">Tiempo para perder</span>
152
+							</div>
153
+						</div>
154
+					</div>
155
+				</div>
156
+			</div>
157
+		</div>
158
+	</section>
159
+
160
+
161
+	<!-- jQuery -->
162
+	<script src="js/jquery.min.js"></script>
163
+	<!-- jQuery Easing -->
164
+	<script src="js/jquery.easing.1.3.js"></script>
165
+	<!-- Bootstrap -->
166
+	<script src="js/bootstrap.min.js"></script>
167
+	<!-- Waypoints -->
168
+	<script src="js/jquery.waypoints.min.js"></script>
169
+	<!-- Stellar Parallax -->
170
+	<script src="js/jquery.stellar.min.js"></script>
171
+	<!-- Counters -->
172
+	<script src="js/jquery.countTo.js"></script>
173
+	<!-- Main JS (Do not remove) -->
174
+	<script src="js/main.js"></script>
175
+
176
+	</body>
177
+</html>