Skip to content

Commit 826aaff

Browse files
Merge pull request #6 from contentstack/dev
Dev
2 parents 42c36a4 + 6879827 commit 826aaff

File tree

16 files changed

+605
-298
lines changed

16 files changed

+605
-298
lines changed

.gitignore

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,5 @@ venv.bak/
104104

105105
# mypy
106106
.mypy_cache/
107-
108-
109107
.idea/
110-
# OS generated files #
111-
.DS_Store
112-
.DS_Store?
113-
.DS_Store
108+
.vscode/

CHANGELOGS.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11

2-
##v0.0.1
3-
Initial release of the python Content Delivery API SDK.
2+
## version 1.0.0
3+
### date 15-Nov-2019
4+
5+
Initial release for the contentstack-python-sdk for content delivery API.
6+
7+
--------------------------------------------------------------------

Example/contentstack-news/README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
[![Contentstack](https://www.contentstack.com/docs/static/images/contentstack.png)](https://www.contentstack.com/)
2+
3+
## WebApp Example for Contentstack-python-sdk
4+
5+
### Prerequisite
6+
7+
You will need python 3 installed on your machine. You can install it from [here](https://www.python.org/ftp/python/3.7.4/python-3.7.4-macosx10.9.pkg).
8+
9+
### Setup and Installation
10+
11+
To use the Contentstack Python SDK to your existing project, perform the steps given below:
12+
13+
*Install pip contentstack*
14+
15+
```
16+
pip contentstack
17+
```
18+
19+
Creating **webapp** using flask and contentstack
20+
21+
Initialise. Flask and contentstack
22+
23+
flask and contentstack initialisation:
24+
>>> pip flask
25+
>>> pip contentstack
26+
create a directory named contentstack-webapp, create a python file inside name app.py or anything of your liking.
27+
28+
put below structure provided by [flask]([https://palletsprojects.com/p/flask/](https://palletsprojects.com/p/flask/))
29+
30+
from flask import Flask
31+
from contentstack import Stack
32+
33+
app = Flask(__name__)
34+
35+
stack = Stack(api_key='api_key', access_token='access_token', environment='environment')
36+
query = stack.content_type('content_type_id').query()
37+
response = query.find()
38+
39+
@app.route('/')
40+
def hello():
41+
return 'Hello world'
42+
43+
Run the project by following command:
44+
45+
$ env FLASK_APP=hello.py flask run
46+
* Serving Flask app "hello"
47+
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
48+
49+
50+
51+
That's It.
52+
53+
Thank you
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/* #DE4A48 */
2+
3+
body {
4+
background: #fafafa;
5+
color: #333333;
6+
margin-top: 5rem;
7+
}
8+
9+
h1, h2, h3, h4, h5, h6 {
10+
color: #444444;
11+
}
12+
13+
.bg-steel {
14+
background-color: #5f788a;
15+
}
16+
17+
.site-header .navbar-nav .nav-link {
18+
color: #cbd5db;
19+
}
20+
21+
.site-header .navbar-nav .nav-link:hover {
22+
color: #ffffff;
23+
}
24+
25+
.site-header .navbar-nav .nav-link.active {
26+
font-weight: 500;
27+
}
28+
29+
.content-section {
30+
background: #ffffff;
31+
padding: 10px 20px;
32+
border: 1px solid #dddddd;
33+
border-radius: 3px;
34+
margin-bottom: 20px;
35+
}
36+
37+
.article-title {
38+
color: #444444;
39+
}
40+
41+
a.article-title:hover {
42+
color: #428bca;
43+
text-decoration: none;
44+
}
45+
46+
.article-content {
47+
white-space: pre-line;
48+
}
49+
50+
.article-img {
51+
height: 65px;
52+
width: 65px;
53+
margin-right: 16px;
54+
}
55+
56+
.article-metadata {
57+
padding-bottom: 1px;
58+
margin-bottom: 4px;
59+
border-bottom: 1px solid #e3e3e3
60+
}
61+
62+
.article-metadata a:hover {
63+
color: #333;
64+
text-decoration: none;
65+
}
66+
67+
.article-svg {
68+
width: 25px;
69+
height: 25px;
70+
vertical-align: middle;
71+
}
72+
73+
.account-img {
74+
height: 125px;
75+
width: 125px;
76+
margin-right: 20px;
77+
margin-bottom: 16px;
78+
}
79+
80+
.account-heading {
81+
font-size: 2.5rem;
82+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{% extends 'layout.html' %}
2+
{% block content %}
3+
<h1>About Page</h1>
4+
<p>Contentstack™ is the hub powering omnichannel content, digital experiences,
5+
and personalized customer journeys. It is the industry
6+
leader in the headless content management system (CMS) category.
7+
Marquee customers include Activision Blizzard, Amway, Best Buy, Chase,
8+
Cisco, Dell, Ellie Mae, Express, Farm Bureau Insurance, J.D. Power, Martha Stewart,
9+
Miami HEAT, Riot Games, Shell, Sky, and Walmart.
10+
Contentstack sits at the heart of an award-winning Digital Experience Platform (DXP)
11+
and is the exclusive API-first CMS for the SAP Cloud.</p>
12+
{% endblock content %}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{% extends 'layout.html' %}
2+
{% block content %}
3+
{% for post in news %}
4+
<article class="media content-section">
5+
<div class="media-body">
6+
<div class="article-metadata">
7+
<a class="mr-2" href="#">{{ post.json.top_news }}</a>
8+
<small class="text-muted">{{ post.json.created_at }}</small>
9+
</div>
10+
<h3><a class="article-title" href="#">{{ post.json.title }}</a></h3>
11+
<p class="article-content">{{ post.json.body | safe }}</p>
12+
</div>
13+
</article>
14+
{% endfor %}
15+
{% endblock content %}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<!-- Required meta tags -->
5+
<meta charset="utf-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
7+
8+
<!-- Bootstrap CSS -->
9+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
10+
11+
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='main.css') }}">
12+
13+
{% if title %}
14+
<title>contentstack-news - {{ title }}</title>
15+
{% else %}
16+
<title>contentstack-news</title>
17+
{% endif %}
18+
</head>
19+
<body>
20+
<header class="site-header">
21+
<nav class="navbar navbar-expand-md navbar-dark bg-steel fixed-top">
22+
<div class="container">
23+
<a class="navbar-brand mr-4" href="/">Contentstack-News</a>
24+
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggle" aria-controls="navbarToggle" aria-expanded="false" aria-label="Toggle navigation">
25+
<span class="navbar-toggler-icon"></span>
26+
</button>
27+
<div class="collapse navbar-collapse" id="navbarToggle">
28+
<div class="navbar-nav mr-auto">
29+
<a class="nav-item nav-link" href="/">Home</a>
30+
<a class="nav-item nav-link" href="/about">About</a>
31+
</div>
32+
<!-- Navbar Right Side -->
33+
<!-- <div class="navbar-nav">
34+
<a class="nav-item nav-link" href="/login">Login</a>
35+
<a class="nav-item nav-link" href="/register">Register</a>
36+
</div> -->
37+
</div>
38+
</div>
39+
</nav>
40+
</header>
41+
<main role="main" class="container">
42+
<div class="row">
43+
<div class="col-md-8">
44+
{% block content %}{% endblock %}
45+
</div>
46+
<!-- <div class="col-md-4">
47+
<div class="content-section">
48+
<h3>Our Sidebar</h3>
49+
<p class='text-muted'>You can put any information here you'd like.
50+
<ul class="list-group">
51+
<li class="list-group-item list-group-item-light">Latest Posts</li>
52+
<li class="list-group-item list-group-item-light">Announcements</li>
53+
<li class="list-group-item list-group-item-light">Calendars</li>
54+
<li class="list-group-item list-group-item-light">etc</li>
55+
</ul>
56+
</p>
57+
</div>
58+
</div> -->
59+
</div>
60+
</main>
61+
62+
63+
<!-- Optional JavaScript -->
64+
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
65+
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
66+
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
67+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
68+
</body>
69+
</html>

contentstack/__init__.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
11

2-
# __init__
3-
# contentstack
4-
#
5-
# Created by Shailesh Mishra on 22/06/19.
6-
# Copyright © 2019 Contentstack. All rights reserved.
2+
"""
3+
__init__.py
4+
contentstack
5+
Created by Shailesh Mishra on 22/06/19.
6+
Copyright 2019 Contentstack. All rights reserved.
7+
"""
78

89
import warnings
9-
__author__ = 'Shailesh Mishra'
10+
11+
__author__ = 'Contentstack'
1012
__status__ = 'debug'
1113
__version__ = '1.0.0'
1214
__package__ = 'contentstack'
1315
__endpoint__ = 'cdn.contentstack.io'
16+
__email__ = "[email protected]"
1417

1518
from .entry import Entry
1619
from .asset import Asset
1720
from .config import Config
1821
from .content_type import ContentType
19-
from .errors import Error, ConfigError, FileModeWarning
22+
from .errors import Error, FileModeWarning
2023
from .http_connection import HTTPConnection
24+
from .stack import Stack
2125

22-
# Set a default logger to prevent "No handler found" warnings
23-
# Set default logging handler to avoid "No handler found" warnings.
2426
import logging
2527
from logging import NullHandler
26-
2728
logging.getLogger(__name__).addHandler(NullHandler())
28-
29-
# FileModeWarnings go off per the default.
3029
warnings.simplefilter('default', FileModeWarning, append=True)

0 commit comments

Comments
 (0)