{"id":4034,"date":"2019-10-26T06:47:00","date_gmt":"2019-10-26T04:47:00","guid":{"rendered":"https:\/\/pythonprogramming.altervista.org\/?p=4034"},"modified":"2019-10-27T12:42:35","modified_gmt":"2019-10-27T11:42:35","slug":"python-on-glitch-com-without-flask","status":"publish","type":"post","link":"https:\/\/pythonprogramming.altervista.org\/python-on-glitch-com-without-flask\/","title":{"rendered":"Python on Glitch.com without Flask"},"content":{"rendered":"<p>We can use <strong>Python 3<\/strong> on Glitch.com. I showed you how (see the posts at the end of this post) to do it with flask. Now I want to show how to do it with just Python.<\/p>\n<p><strong>Glitch.com<\/strong> allows you to create web apps for free, so it is greatly reccomanded. The IDE that you can use make you see the results of your code immediately, so it&#8217;s superfun and supereasy to use. Another massive fact is that you can use Python at ease. Let&#8217;s see how.<\/p>\n<p>You can access to Python 3.5 through a virtual machine that runs <strong>Ubuntu 16.04.5.<\/strong> Go create an account on Glitch.com and start a new project. You will need the following files to get started:<\/p>\n<ul>\n<li>requirements.txt<\/li>\n<li>start.sh<\/li>\n<li>app.py<\/li>\n<\/ul>\n<h2>requirements.txt<\/h2>\n<p>This is the firs file you&#8217;ll need. Into this one write:<\/p>\n<pre class=\"lang:default decode:true \">aiohttp==2.3.10<\/pre>\n<h2>start.sh<\/h2>\n<p>This is the content<\/p>\n<pre class=\"lang:default decode:true \">pip3 install --user -r requirements.txt \r\npython3 app.py<\/pre>\n<h2>app.py<\/h2>\n<p>This is what you need in app.py to make the site work<\/p>\n<pre class=\"lang:default decode:true \">from aiohttp import web\r\n\r\nasync def handle_index(request):\r\n  return web.Response(text=\"\"\"\r\nMy First Async Python 3 Web App\r\n\r\nWelcome to my first app on Glitch.com made in Python 3.5.\r\n\r\n\"\"\")\r\n\r\nif __name__ == '__main__':\r\n  app = web.Application()\r\n  app.router.add_get('\/', handle_index)\r\n  web.run_app(app)<\/pre>\n<p>Now, when you will show your project you will see:<\/p>\n<p style=\"text-align: center;\"><strong>My First Async Python 3 Web App<\/strong><\/p>\n<p>in the browser.<\/p>\n<p><a href=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/10\/python_glitch.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4036\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/10\/python_glitch.png\" alt=\"\" width=\"762\" height=\"259\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/10\/python_glitch.png 762w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/10\/python_glitch-320x109.png 320w\" sizes=\"auto, (max-width: 762px) 100vw, 762px\" \/><\/a><\/p>\n<p>This is the site on glitch.me <a href=\"https:\/\/pythonskratch.glitch.me\/\">pythonskratch.glich.me<\/a><\/p>\n<script>\r\n\tif (typeof title != \"undefined\")\r\n\t{let title = \"Glitch.com (with flask)\";\r\n\tlet links = [];}\r\n\telse\r\n\t{title = \"Glitch.com (with Flask)\";}\r\n\r\n\tlinks = [\r\n[\"https:\/\/pythonprogramming.altervista.org\/how-to-authorize-users-to-access-to-personal-pages-with-glitch-com\/\",\"Access with auth on glitch.me\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/video-python-3-on-glitch-com\/\",\"Python 3 on Glitch (Live code)\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/flask-and-python-3-on-glitch-in-a-couple-of-lines\/\",\"Python 3 on Glitch with Flask (2)\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/python-on-glitch-com-without-flask\/\",\"Python on Glitch.com without flask\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/python-3-with-flask-on-glitch-com\/\",\"Python 3 on Glitch.com\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/python-flask-on-glitch-edited-with-visual-studio-code\/\",\"Visual studio code and Glitch.com\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/how-to-import-a-blog-on-glitch-com-from-github\/\",\"Import site from Github in Glitch.com\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/publish-app-or-blog-with-glitch-com-and-python-in-no-time\/\",\"Publish a Flask Blog in Glitch.com\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/put-our-flask-blog-on-glitch-com-for-free\/\",\"Free Flask blog wiht Python on GLitch.com\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/a-brief-guide-to-pil-python-image-library\/\",\"My Flask site on PIL on Glitch.com\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/how-to-render-html-into-flask-variables-passed-to-the-pages\/\",\"Render Html in Flask on Glitch.com\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/what-if-you-got-dns_probe_finished_nxdomain-with-glitch-me-sites\/\",\"Cannot see glithc.me site (dns)\"]\r\n\t\t];\t\t \r\n<\/script>\r\n<script>\r\n\t\r\nif (typeof next2 != \"undefined\"){let next2 = 0;}\r\n\t\r\nnext2 = 0;\r\n\thtml = \"\";\/\/<b style='color:coral;font-size:1.2em'>Other posts about \" + title + \"<\/b><br>\";\r\nfor (address of links) \r\n{\r\n\r\n\tif (next2 == 1){\r\n\t\thtml += \"<div style='background:coral'>\";\r\n\t\thtml += \"Next link => <a href='\" + address[0] + \"'>\" + address[1] + \"<\/a>\";\r\n\t\thtml += \"<\/div><br>\";\r\n\t\tnext2 = 0;\r\n\t}\r\n\tif (address[0] == document.URL) {\r\n\t\tnext2 = 1;\r\n\t}\r\n}\r\n\r\nif (typeof next != \"undefined\") {let next = 0;}\r\nif (typeof addressStart != \"undefined\") {let addressStart = \"\";}\r\nnext = 0;\r\naddressStart = \"<a href='\";\r\nfor (address of links) {\r\n\tif (next == 1){\r\n\t\thtml += \">>>\" + addressStart + address[0] + \"'>\" + address[1] + \"<\/a><br>\";\r\n\t\tnext = 0;\r\n\t}\r\n\telse if (addressStart + address[0] != document.URL)\r\n\t{\r\n\t\thtml += addressStart + address[0] + \"'>\" + address[1] + \"<\/a><br>\";\r\n\t}\r\n\telse\r\n\t{\r\n\t\tnext = 1;\r\n\t\tnext_address = address[0]\r\n\t\tnext_title = address[1]\r\n\t\thtml += \"<span style='color:gray'>\" + address[1] + \"<\/span><br>\";\r\n\t}\r\n\r\n}\r\n\r\n\thtml += `<span style=\"font-size:8px\">Powered by <a href=\"https:\/\/pythonprogramming.altervista.org\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2673\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/altervista2.png\" alt=\"\" width=\"70\" height=\"25\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/altervista2.png 156w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/altervista2-150x56.png 150w\" sizes=\"auto, (max-width: 70px) 100vw, 70px\" \/>pythonprogramming.altervista.org<\/a><\/span>`\r\n\thtml = \"<div style='background:yellow'>\" + html + \"<\/div>\";\r\n\tdocument.write(html)\r\n<\/script>\n","protected":false},"excerpt":{"rendered":"Python 3 from skratch on Glitch.com and Glitch.me\n<a class=\"moretag\" href=\"https:\/\/pythonprogramming.altervista.org\/python-on-glitch-com-without-flask\/\"> [...]<\/a>","protected":false},"author":1,"featured_media":4037,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[431],"tags":[433,538,603,606],"class_list":["post-4034","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-glitch-com","tag-glitch-com","tag-glitch-me","tag-python-3","tag-python3"],"avopt_banners_inside_post":true,"avopt_banners_on_page":true,"av_copy_from":"","av_sharing_message":"","av_sharing_allowed":true,"av_sharing_on":{"fb":[],"tw":[]},"av_allow_affiliate_banner":false,"av_allow_affiliate_multi_banner":false,"av_show_affiliation_buy_button":false,"av_post_rating":true,"av_have_post_rating_value":false,"av_is_artificial_intelligence_content":false,"_links":{"self":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/4034","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/comments?post=4034"}],"version-history":[{"count":4,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/4034\/revisions"}],"predecessor-version":[{"id":4051,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/4034\/revisions\/4051"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media\/4037"}],"wp:attachment":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media?parent=4034"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/categories?post=4034"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/tags?post=4034"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}