Files
Library/docs/.vitepress/dist/rebel_coding/step5.html

77 lines
36 KiB
HTML
Raw Normal View History

2026-01-09 23:05:52 -05:00
<!DOCTYPE html>
<html lang="en-US" dir="ltr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Servers and more | DreamFreely Library</title>
<meta name="description" content="Community Conscious Creations">
<meta name="generator" content="VitePress v2.0.0-alpha.15">
<link rel="preload stylesheet" href="/assets/style.tE5om2fv.css" as="style">
<link rel="preload stylesheet" href="/vp-icons.css" as="style">
<script type="module" src="/assets/app.CNf1Hw3L.js"></script>
<link rel="preload" href="/assets/inter-roman-latin.Di8DUHzh.woff2" as="font" type="font/woff2" crossorigin="">
<link rel="modulepreload" href="/assets/chunks/theme.DVARhRSD.js">
<link rel="modulepreload" href="/assets/chunks/framework.BfS8l2sS.js">
<link rel="modulepreload" href="/assets/rebel_coding_step5.md.Dpyx0NUO.lean.js">
<script id="check-dark-mode">(()=>{const e=localStorage.getItem("vitepress-theme-appearance")||"auto",a=window.matchMedia("(prefers-color-scheme: dark)").matches;(!e||e==="auto"?a:e==="dark")&&document.documentElement.classList.add("dark")})();</script>
<script id="check-mac-os">document.documentElement.classList.toggle("mac",/Mac|iPhone|iPod|iPad/i.test(navigator.platform));</script>
</head>
<body>
<div id="app"><div class="Layout" data-v-1df9f90f><!--[--><!--]--><!--[--><span tabindex="-1" data-v-331ec75c></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-331ec75c>Skip to content</a><!--]--><!----><header class="VPNav" data-v-1df9f90f data-v-da52a441><div class="VPNavBar" data-v-da52a441 data-v-70946a35><div class="wrapper" data-v-70946a35><div class="container" data-v-70946a35><div class="title" data-v-70946a35><div class="VPNavBarTitle has-sidebar" data-v-70946a35 data-v-1e38c6bc><a class="title" href="/" data-v-1e38c6bc><!--[--><!--]--><!----><span data-v-1e38c6bc>DreamFreely Library</span><!--[--><!--]--></a></div></div><div class="content" data-v-70946a35><div class="content-body" data-v-70946a35><!--[--><!--]--><div class="VPNavBarSearch search" data-v-70946a35><!----></div><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-70946a35 data-v-39714824><span id="main-nav-aria-label" class="visually-hidden" data-v-39714824> Main Navigation </span><!--[--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/welcome/" tabindex="0" data-v-39714824 data-v-52a1d768><!--[--><span data-v-52a1d768>Welcome</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/welcome/support.html" tabindex="0" data-v-39714824 data-v-52a1d768><!--[--><span data-v-52a1d768>Support</span><!--]--></a><!--]--><!--]--></nav><!----><div class="VPNavBarAppearance appearance" data-v-70946a35 data-v-6c893767><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title aria-checked="false" data-v-6c893767 data-v-5337faa4 data-v-1d5665e3><span class="check" data-v-1d5665e3><span class="icon" data-v-1d5665e3><!--[--><span class="vpi-sun sun" data-v-5337faa4></span><span class="vpi-moon moon" data-v-5337faa4></span><!--]--></span></span></button></div><div class="VPSocialLinks VPNavBarSocialLinks social-links" data-v-70946a35 data-v-0394ad82 data-v-d07f11e6><!--[--><a class="VPSocialLink no-icon" href="https://canin.dreamfreely.org" aria-label="bookalope" target="_blank" rel="me noopener" data-v-d07f11e6 data-v-591a6b30><span class="vpi-social-bookalope"></span></a><a class="VPSocialLink no-icon" href="https://shop.dreamfreely.org" aria-label="tina" target="_blank" rel="me noopener" data-v-d07f11e6 data-v-591a6b30><span class="vpi-social-tina"></span></a><a class="VPSocialLink no-icon" href="https://digisnaxx.com" aria-label="ghostery" target="_blank" rel="me noopener" data-v-d07f11e6 data-v-591a6b30><span class="vpi-social-ghostery"></span></a><a class="VPSocialLink no-icon" href="https://manifestingempathy.com" aria-label="hasura" target="_blank" rel="me noopener" data-v-d07f11e6 data-v-591a6b30><span class="vpi-social-hasura"></span></a><!--]--></div><div class="VPFlyout VPNavBarExtra extra" data-v-70946a35 data-v-bf2fac68 data-v-42cb505d><button type="button" class="button" aria-haspopup="true" aria-expanded="false" aria-label="extra navigation" data-v-42cb505d><span class="vpi-more-horizontal icon" data-v-42cb505d></span></button><div class="menu" data-v-42cb505d><div class="VPMenu" data-v-42cb505d data-v-25a6cce8><!----><!--[--><!--[--><!----><div class="group" data-v-bf2fac68><div class="item appearance" data-v-bf2fac68><p class="label" data-v-bf2fac68>Appearance</p><div class="appearance-action" data-v-bf2fac68><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title aria-checked="false" data-v-bf2fac68 data-v-5337faa4 data-v-1d5665e3><span class="check" data-v-1d5665e3><span class="icon" data-v-1d5665e3><!--[--><span class="vpi-sun sun" data-v-5337faa4></span><span class="vpi-moon moon" data-v-5337faa4></span><!--]--></span></span></button></div></div></div><div class="group" data-v-bf2fac68><div class="item social-links" data-v-bf2fac68><div class="VPSocialLinks social-links-list" data-v-bf2fac68 data-v-d07f11e6><!--[--><a class="VPSocialLink no-icon" href="https://canin.dreamfreely.org" aria-label="bookalope" target="_blank" rel="me noopener" data-v-d07f11e6 data-v-591a6b30><span class="vpi-social-bookalope"></span></a><a class
title = models.CharField(max_length=255)
pub_date = models.DateTimeField(auto_now_add=False)
content = models.TextField()
slug = models.SlugField(unique=True, max_length=255)
published = models.BooleanField(default=False)
# category = models.ForeignKey(Category, blank=True, null=True, on_delete=&quot;PROTECT&quot;)
# tags = models.ManyToManyField(Tag, blank=True)
class Meta:
ordering = [&#39;-pub_date&#39;]
def __unicode__(self):
return u&#39;%s&#39; % self.title
def __str__(self):
return u&#39;%s&#39; % self.title
</code></pre><h3 id="views-py" tabindex="-1">Views.py <a class="header-anchor" href="#views-py" aria-label="Permalink to “Views.py”"></a></h3><pre><code>@permission_classes([])
@authentication_classes([])
class VideosAPIView(generics.ListAPIView):
serializer_class = VideoSerializer
def get_queryset(self):
queryset = Video.objects.all()
lang = self.request.query_params.get(&#39;q&#39;, None)
if lang == None:
# lang = 0
queryset = Video.objects.filter(published=True).all()
else:
queryset = Video.objects.filter(published=True, target_language=lang).all()
return queryset
</code></pre><h3 id="urls-py" tabindex="-1">URLS.py <a class="header-anchor" href="#urls-py" aria-label="Permalink to “URLS.py”"></a></h3><pre><code>urlpatterns = [
url(r&#39;^api/searchvids$&#39;, SearchVideosAPIView.as_view(), name=&quot;search-vids&quot;),
url(r&#39;^api/imenu$&#39;, SocialAPIView.as_view(), name=&quot;social&quot;),
url(r&#39;^api/iposts$&#39;, PostsAPIView.as_view(), name=&quot;posts&quot;),
url(r&#39;^api/ivids$&#39;, VideosAPIView.as_view(), name=&quot;videos&quot;),
url(r&#39;^api/ivid/[-@\w]+/$&#39;, VideoAPIView.as_view(), name=&quot;video&quot;),
url(r&#39;^api/iverse$&#39;, VerseAPIView.as_view(), name=&quot;verse&quot;),
url(r&#39;^api/ividask$&#39;, RequestAPIView.as_view(), name=&quot;videoask&quot;),
url(r&#39;^api/songsubmit$&#39;, UserAvatarUpload.as_view(), name=&quot;songsubmit&quot;),
url(r&#39;^api/getidiokers$&#39;, GetIdiokersAPIView.as_view(), name=&quot;idiokers&quot;),
url(r&#39;^api/getgenres$&#39;, GetGenreAPIView.as_view(), name=&quot;musicgenres&quot;),
]
</code></pre><h1 id="apis-the-django-rest-framework" tabindex="-1">APIS &amp; the Django REST Framework <a class="header-anchor" href="#apis-the-django-rest-framework" aria-label="Permalink to “APIS &amp; the Django REST Framework”"></a></h1><hr><p>As mentioned earlier, we aren&#39;t bothering with Django Templates, rather all of our data will be consumed by a JavaScript client created using the VueJS framework.</p><p>Our Django server&#39;s duty is to serve API endpoints, and we do this using the <a href="https://www.django-rest-framework.org/" target="_blank" rel="noreferrer">Django REST Framework</a> .</p><p><strong>REST</strong> stands for <a href="https://en.wikipedia.org/wiki/Representational_state_transfer" target="_blank" rel="noreferrer">Representation State Transfer</a> ; and it is a style of software architecture to define how data is transferred between web services.</p><p>Other architectures include <a href="https://en.wikipedia.org/wiki/SOAP" target="_blank" rel="noreferrer">SOAP</a> and <a href="https://en.wikipedia.org/wiki/GraphQL" target="_blank" rel="noreferrer">GraphQL</a> .</p><h3 id="serializers-py" tabindex="-1">Serializers.py <a class="header-anchor" href="#serializers-py" aria-label="Permalink to “Serializers.py”"></a></h3><p>RESTful frameworks operate by serializing, or conforming, data into a known structure and transferring this known structure between web services. And to do that we use what is called a serializer.</p><p>Just as our models define how the data is stored in our databases, serializers define the forme and shape of data that is transferred via API calls to our RESTful API endpoints.</p><pre><code>class PostSerializer(serializers.ModelSerializer):
class Meta:
model = Post
fields = &#39;__all__&#39;
# fields = (&#39;id&#39;, &#39;name&#39;,)
</code></pre><h1 id="clone-sf-project" tabindex="-1">Clone SF Project <a class="header-anchor" href="#clone-sf-project" aria-label="Permalink to “Clone SF Project”"></a></h1><hr><pre><code>git clone
git clone
</code></pre><h1 id="writing-your-first-web-scraper" tabindex="-1">Writing your first web-scraper <a class="header-anchor" href="#writing-your-first-web-scraper" aria-label="Permalink to “Writing your first web-scraper”"></a></h1><hr><h1 id="attach-scraper-to-orm" tabindex="-1">Attach Scraper to ORM <a class="header-anchor" href="#attach-scraper-to-orm" aria-label="Permalink to “Attach Scraper to ORM”"></a></h1><hr><p>Learn pupa etc …</p><pre><code>pupa init NewCity
</code></pre><h1 id="your-first-pull-request" tabindex="-1">Your First Pull Request <a class="header-anchor" href="#your-first-pull-request" aria-label="Permalink to “Your First Pull Request”"></a></h1><hr><p>Fork the project</p><h1 id="exploring-the-sf-project" tabindex="-1">Exploring the SF Project <a class="header-anchor" href="#exploring-the-sf-project" aria-label="Permalink to “Exploring the SF Project”"></a></h1><hr></div></div></main><footer class="VPDocFooter" data-v-7011f0d8 data-v-e257564d><!--[--><!--]--><!----><nav class="prev-next" aria-labelledby="doc-footer-aria-label" data-v-e257564d><span class="visually-hidden" id="doc-footer-aria-label" data-v-e257564d>Pager</span><div class="pager" data-v-e257564d><a class="VPLink link pager-link prev" href="/rebel_coding/v2Orient.html" data-v-e257564d><!--[--><span class="desc" data-v-e257564d>Previous page</span><span class="title" data-v-e257564d>Planning Our App</span><!--]--></a></div><div class="pager" data-v-e257564d><a class="VPLink link pager-link next" href="/rebel_coding/step6.html" data-v-e257564d><!--[--><span class="desc" data-v-e257564d>Next page</span><span class="title" data-v-e257564d>Step 2: Client</span><!--]--></a></div></nav></footer><!--[--><!--]--></div></div></div><!--[--><!--]--></div></div><!----><!--[--><!--]--></div></div>
<script>window.__VP_HASH_MAP__=JSON.parse("{\"api-examples.md\":\"CLsEsApn\",\"df_guide_1_basic_psych.md\":\"DwYn8aJz\",\"df_guide_2_medi_vibes.md\":\"BL-BuG9R\",\"df_guide_3_with_loneliness.md\":\"Bo6ULJ8y\",\"df_guide_4_enter_alchemy.md\":\"DcZx6NAy\",\"df_guide_5_test_ethic.md\":\"nyIQpJwM\",\"df_guide_6_social_physics.md\":\"CNA2jQCU\",\"df_guide_7_quantum_realm.md\":\"BFXlzHiT\",\"df_guide_8_topol.md\":\"BjXlxBWE\",\"df_guide_appendices.md\":\"CDMgMihK\",\"df_guide_index.md\":\"xD8OyHvK\",\"exocto_analytics.md\":\"BM3Pg91r\",\"exocto_appendices.md\":\"sVwSvUYe\",\"exocto_automation.md\":\"DEvrDE4y\",\"exocto_cooltools.md\":\"BC6_kCf0\",\"exocto_index.md\":\"DHdM3bQG\",\"exocto_licences.md\":\"Dk7QbXAY\",\"exocto_mailinglists.md\":\"D42Z_f3S\",\"exocto_payments.md\":\"BwzhBIvJ\",\"exocto_seo101.md\":\"CRJt4LE8\",\"exocto_socialmedia.md\":\"B9APVBs4\",\"exocto_websites.md\":\"6J92idVL\",\"index.1.md\":\"D7r5zJY5\",\"index.md\":\"DcciJnS6\",\"markdown-examples.md\":\"B9ZdJivL\",\"mempath_able-ism.md\":\"Dof--8TS\",\"mempath_appendices.md\":\"DBar2q2m\",\"mempath_gender-studies.md\":\"BcTGweUU\",\"mempath_index.md\":\"Dn2o6A3M\",\"mempath_notes.huggingface.md\":\"CGBrM3lA\",\"mempath_onward.md\":\"DxhCj56a\",\"mempath_openai.playground.md\":\"C3ceZL9Q\",\"mempath_outline.huggingface.md\":\"BFuiOEVO\",\"mempath_power-dynamics.md\":\"CQWNxegt\",\"mempath_racism.md\":\"CxVF4Hbn\",\"mempath_sexism.md\":\"Db1tqU4H\",\"rebel_coding_appendices.md\":\"gQ1t-5b7\",\"rebel_coding_index.md\":\"BgfENPxu\",\"rebel_coding_orientation.md\":\"BjaO66hJ\",\"rebel_coding_step1.md\":\"CgXIS7sX\",\"rebel_coding_step2.md\":\"C1zU29Lh\",\"rebel_coding_step3.md\":\"DPGBP964\",\"rebel_coding_step4.md\":\"Bp6KMb-K\",\"rebel_coding_step5.md\":\"Dpyx0NUO\",\"rebel_coding_step6.md\":\"VjnlTvFQ\",\"rebel_coding_step7.md\":\"Cv22hGLG\",\"rebel_coding_step8.md\":\"hfdnDA5D\",\"rebel_coding_termintro.md\":\"yqyXwJUh\",\"rebel_coding_v2.md\":\"C_Ab_PCg\",\"rebel_coding_v2orient.md\":\"Cih4N80W\",\"welcome_canin.md\":\"BVaWnSlf\",\"welcome_dreamfreely.md\":\"C8ZaDhcw\",\"welcome_index.md\":\"IohpDKGr\",\"welcome_support.md\":\"CIaYjdmV\"}");window.__VP_SITE_DATA__=JSON.parse("{\"lang\":\"en-US\",\"dir\":\"ltr\",\"title\":\"DreamFreely Library\",\"description\":\"Community Conscious Creations\",\"base\":\"/\",\"head\":[],\"router\":{\"prefetchLinks\":true},\"appearance\":true,\"themeConfig\":{\"nav\":[{\"text\":\"Welcome\",\"link\":\"/welcome/\"},{\"text\":\"Support\",\"link\":\"/welcome/support\"}],\"sidebar\":[{\"text\":\"Welcome\",\"items\":[{\"text\":\"Chibu / Hola / Hello\",\"link\":\"/welcome/\"},{\"text\":\"About DreamFreely\",\"link\":\"/welcome/dreamfreely\"},{\"text\":\"About Canin Carlos\",\"link\":\"/welcome/canin\"}]},{\"text\":\"Rebel Coding 101\",\"items\":[{\"text\":\"Intro to Coding\",\"link\":\"/rebel_coding/\"},{\"text\":\"Orientation\",\"link\":\"/rebel_coding/orientation\"},{\"text\":\"Intro to CLI\",\"link\":\"/rebel_coding/termintro\"},{\"text\":\"Step 1: HTML & CSS\",\"link\":\"/rebel_coding/step1\"},{\"text\":\"Step 2: JavaScript\",\"link\":\"/rebel_coding/step2\"},{\"text\":\"Step 3: Python Scrapers\",\"link\":\"/rebel_coding/step3\"},{\"text\":\"Step 4: The Full Stack\",\"link\":\"/rebel_coding/step4\"},{\"text\":\"Appendices\",\"link\":\"/rebel_coding/appendices\"}]},{\"text\":\"Rebel Coding 102\",\"items\":[{\"text\":\"Reviewing the Full-Stack\",\"link\":\"/rebel_coding/v2\"},{\"text\":\"Planning Our App\",\"link\":\"/rebel_coding/v2Orient\"},{\"text\":\"Step 1: Server\",\"link\":\"/rebel_coding/step5\"},{\"text\":\"Step 2: Client\",\"link\":\"/rebel_coding/step6\"},{\"text\":\"Step 3: Deployment\",\"link\":\"/rebel_coding/step7\"},{\"text\":\"Step 4: Scaling, etc\",\"link\":\"/rebel_coding/step8\"},{\"text\":\"More Appendices\",\"link\":\"/rebel_coding/more-appendices\"}]},{\"text\":\"Manifesting Empathy\",\"items\":[{\"text\":\"Welcome\",\"link\":\"/mempath/\"},{\"text\":\"The Egg (0-5)\",\"link\":\"/mempath/egg\"},{\"text\":\"The Hatchling (5-12)\",\"link\":\"/mempath/hatchling\"},{\"text\":\"Flight (12-18)\",\"link\":\
</body>
</html>