#web-development
2 messages · Page 77 of 1
Probably because you had a charfield with the value "1st bool field" and you tried to change that field to a boolean field
Is anyone familiar with using the Fetch API and django? I am trying to access a json file and pass it to my front end, but fetch keeps returning 404.
Is anyone here with Django experience? I daced some problem and stocked
ok, thx for your info
Easiest way to fix your problem @uncut rover is to destroy your database, create a new one, delete all migrations files, and then run the migrations again. There are other ways but they are a bit more complex, if you don't care about your current data I would just do that
Reset the whole thing?
Yea
Ill do that
The database only
Right now this is not a flask or django problem that you have, it's a basic database problem where you're trying to convert a text column to a boolean column while keeping text data
I have a problem, my flask app doesn't decode % characters from url parameters when on a2hosting shared(Uses apache if i'm not mistaken), but handles it just fine locally
for example for /test/foo%20bar
@app.route('/test', methods=['get'])
@app.route('/test/<title>', methods=['get'])
def test(title=""):
return title
When used on remote hosting it would return foo%20bar and on local it would return foo bar. Can't figure out why
You should slugify your url parameters
But why does it work normally when running locally
And just does that on remote server
@formal shell Switch to back end
How can I use a godaddy domain to redirect to my website made with flask?
Oh so you probably want to launch that then. Or I guess at least purchase a name first. I would look that up on youtube. I think most people are still learning not launching websites here at this point but I could be wrong
@pure walrus I don't think it would be that hard
I bought a domain as a joke, but I want to take the opportunity to learn a little web design
I bought a domain as a joke, but I want to take the opportunity to learn a little web design
@full nimbus 2 things you need to know, SRV and A Records
once you got them covered you'll be able to setup ur domain in no time
and I am sure GoDaddy offer support for such queries
Hi! Im triying to link my .css to my html and it just doesnt work...
look
<head>
<link rel="stylesheet" type="text/css" href="main.css"/>
<meta charset="UTF-8">
<title>Page J</title>
</head
they are in the same folder
and i dont have idea what is happening
can someone help me plsss!?
Are you sure everythings saved
@weak lynx
Also if that code is exactly right you're missing a closing > at the bottom
What were you goiung to type ba
What is your full code ?
let me send it...
try "./main.css"
ok
this is the home.html
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="main.css"/>
<meta charset="UTF-8">
<title>Page J</title>
</head>
this is one part of main.css...
body {
margin: 0;
background-color: slategrey;
font-family: sans-serif;
font-weight: 300;
}
.container {
width: 80%;
margin: 0 auto;
}
try "./main.css"
@dark agate I try it and no, didnt work
there's no body in your html document
if i click ctrl and click it goes to main.css
there's no body in your html document
@dark agate let me sen it
okay
<header>
<div class="container">
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Category</a></li>
</ul>
</nav>
</div>
</header>
</body>
</html>
the background dont change of color... anythin...
Yes also i have triyed static folder outside the templates but dont work either
Do you know what the browser console is @weak lynx ? If yes open it, do you see any error ? If not, press F12 and go to the console tab
you are using flask?
yes
you are using flask?
@dark agate
Do you know what the browser console is @weak lynx ? If yes open it, do you see any error ? If not, press F12 and go to the console tab
@bleak bobcat Yes!! it say theres a error 404 not found... but whyy??
with main.css but why?
if i click control in it it goes to main.css
if u are using flask I think you have to use url_for to link the css
jmmmm can you say me how?
like href={{url_for('static', filename='main.css')}}
but create the static folder and put the css in before doing that
ok...
static folder in or outside templates?
outside
ok
like href={{url_for('static', filename='main.css')}}
@dark agate is this correct?
static is marking a error
what is it saying
let me see...
its....
ignore style.css its another think i was triying
@dark agate
guys
i have my app deployed in heroku for testing
i want to put it "for real"
if i use amazon
how hard is it to deploy the app?
it uses python (flask) and sqlite (i want to change it to pgsql)
i need to implement payment methods too, but i'm a little worried about deploying
heroku basically does everything, how does amazon deal with it?
someone point me to the right direction: how would I go about loading in data by clicking a "load more" button. Using flask by the way and the data is coming in from an API call.
Oh, i fixed it
👍
Sorry ill delete the message
problems that solve themselves
@wild thunder Amazon does nothing and you have to do it all yourself lol
@distant trout sounds like Js magic
😬
@wild thunder easiest, though not the cheapest, is to just launch an ec2 instance, put your app there, hopefully you have a way to run it as a daemon, open the ports, and use route 53 to point a DNS name at the instance.
If it's a container, you can use ecs, but you will need to do some lambda magic (unless the allow opening them up to the world now)
The best way to run in AWS with something flask-like is by not using flask and using chalice instead and just deploying to lambda instead
But even that requires some permissions knowledge
Just stick to heroku until you have a reason not to
I mean, the objective is tô deploy on amazon
Until then, read up on the AWS fundamentals lol
AWS has a lot of docs on how to deploy different things different ways (flask apps included), but none of them exist in the free tier, so plan to pay ~$30-60/mo for something small
Because they do it "the right way" and not the cheapest way lol
Where to deploy something cheap?
It's meant to be a ecommerce
I want to be able to upload files
With a bunch of static images, none of the "big three" will be cheap
Hello, I am having issues with running some asyncronous functions from another file in my flask app to output some information to the browser. Here is the error:
File "H:\programming\personalSteamAuth\steamauthentication.py", line 72, in get_confirms
loop = asyncio.get_event_loop()
File "C:\Users\KUWUPA\AppData\Local\Programs\Python\Python38-32\Lib\asyncio\events.py", line 639, in get_event_loop
raise RuntimeError('There is no current event loop in thread %r.'
RuntimeError: There is no current event loop in thread 'Thread-8'.
Here is the code in my flask app:
import steamauthentication as sa
@app.route('/_load_confirmations/')
def _load_confirmations():
confirmations = sa.get_confirms() # <----- this is the line where I call the function from my other file
print(confirmations)
if len(confirmations) == 0:
return "<p>No confirmations found,</p>"
else:
output = ""
for confirmation in confirmations:
output += render_template("confirmation.html", confirmation=confirmation)
return output```
And here is the function from my other file being called:
```py
def get_confirms():
global loop
loop = asyncio.get_event_loop()
asyncio.ensure_future(get_client())
asyncio.ensure_future(get_confirmations())
loop.run_forever()
return out
Any help would be greatly appreciated :)
I use flask
You should not be using asyncio and flask together
is there any way that i can execute this without having the flask app interfer with the output
because when i use the function from the command line it works to output the information i need
i just need some way of running this function in my flask app and gaining the return value from it
like i guess if there is a way i could have it run the function (on demand) isolated from flask but still get the return value in the flask app
Hey, is there a way to send the flask responses back to the same html page in which the post request was generated?
Thank you for your time!
Hi all. Hope you're all fine.
@jade folio are you talking about like an AJAX request to add a response to the current html?
Yup
I've written two cron jobs and in one of them I'm saving the results in MySQL. Now I want to use Django to view those data in a website. My question is, do I need to do anything in Django about my cron jobs? or they can work quite independently near each other?
yeah @jade folio you can do that by creating a new @App.route('/_example_route/') and having your button call the following function on_click: js function myFunction() { $.ajax({ url: "/_example_route/", success: function(output){ $("#[ID of element you want to add output to]").html(output) }
also in the route be sure to have it return the output you want to add to the html
Thanks a lot for your help. Gonna try this right now.
so for example ```py
@app.route('/_example_route/')
def _example_route():
return "More html"
is it possible that the action attribute in a form prevents the following function from working?
potentially
what action does the form have?
because maybe you could add that to the function you just created and set the forms action to myFunction() rather than using onclick
used to specify a route to get the info entered in the form, as in action="/route"
what action does the form have?
@austere crown
so maybe try set the action to call the AJAX function (in my example myFunction()) and add to that function a second ajax that calls the route which gets the info added to the form
Could you kindly explain a bit how i could do that? Haven't got much knowledge with AJAX
so for example:
html:
<form action="myFunction()">
form in here
</form>```
js:
```js
function myFunction() {
$.ajax({
url: "/route to add data/",
post: form data,
success: function(output){
$("#[ID of element you want to add output to]").html(output)
}
$.ajax({
url: "/_example_route/",
success: function(output){
$("#[ID of element you want to add output to]").html(output)
}```
some thing like this ^
so call the one function with the action
and have it do both your things you want
i dont really have that much knowledge in ajax either but I was doing something kinda similar using it the other day haha
Got it but How do I access the data back in flask?
Earlier used to access it through, request.form.get() Should use the same?
I cannot thank you enough for your help!!
its all good haha
so you are using a button with type submit right?
Yeah
are you able to send the html for your form?
<form action="/quote" method="post" onsubmit="check(); return false;"> <div class="form-group"> <input autocomplete="off" autofocus class="form-control" name="symbol" placeholder="Stock symbol" type="text" id="quote"> </div> <button class="btn btn-primary" type="submit">Quote</button> </form>
The check function currently is just used to check if all the parameters are filled
ok so rather than having an action on your form what you could try is something like:
$(document).ready(function() {
$form('[formid]').on('submit', function(event) {
check();
$.ajax({
data: {
quote : $('quote').val()
},
type: 'POST'
url: "/quote"
success: function(){
$.ajax({
url: "/_example_route/",
success: function(output){
$("#[ID of element you want to add output to]").html(output)
}
}
it may be mis typed but the general idea is to have a js function that waits for the event of the form being submited
and then getting the data inputed to the form
and sending it to the "/quote" url
then after that if it succeeds calling another ajax request which adds more html to the page
👍🏻
Django filters is preety nice
Hey! Do you know a usefull python library to make a social network?
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm
class UserRegisterForm(UserCreationForm):
email=forms.EmailField()
class Meta:
model=User
fields=['username','email','password1','password2'] ```
i get an error that says "local variable 'username' referenced before assignment"
any help?
You didn't declare it
@icy zinc I'm making social media app with flask
Hi! Hows does FastAPI compared to Express for a small team (<5)? I saw some blog posts said that Python required works to do sometimes for async, thread and etc. Meanwhile Node has those built-in.
Hey, I keep getting django.db.utils.OperationalError: no such table: project_classname (not actual that name) which is referring to a class we have in models.py when making migrations. I tried deleting the database, but that didnt work, what can I to?
Did you run migrate?
that happened when running python3 manage.py makemigrations
Oh
Are you trying to reference the model from a foreignkey somewhere where that model isn't imported?
And does the exception give any indication of what line of your code triggered it? I know the errors aren't always helpful as the whole stacktrace can be internal Django code
@lofty matrix https://paste.pythondiscord.com/opiqurelub.sql
there's the full trace
authorize_page("internet") in generate_page.py
is this in a function?
or just in the root level of the file
I think it's root level because that line of the trace say "in <module>"
if that is the case, it looks like that is using the GeneratedPage model before it get's the chance to be created
To make a social network, is it better to use flask or Django?
if that is the case, it looks like that is using the GeneratedPage model before it get's the chance to be created
@lofty matrix let me look
This might break your code as I don't know what that is doing, but if you comment that line, see if the makemigration succeeds
use a database browser to see if the table you made has been created
this is in the stage that generates the instructions for what tables to make, so the database itself isn't relevent yet
This might break your code as I don't know what that is doing, but if you comment that line, see if the makemigration succeeds
@lofty matrixthanks!
it worked :D
🥳
So you'll have to refactor your code so that isn't in the root of your module. Because it is, it is run when makemigration runs
https://docs.djangoproject.com/en/3.0/howto/custom-management-commands/ could be useful. Maybe https://docs.djangoproject.com/en/2.2/howto/initial-data/ . Depends on your needs
hello, can anyone hit me up with any django project code(github), intermediate-expert level, i would like to know how intermediate django programmers solve problems.
Good day! In my project I want to make library site. So I have book, it's author and it's genre. At home page I want to select a book from the drop-down list by its title. How can I implement this through the views.py and template files ?
you want to implement filtering ??? @regal furnace
Let's say so at home page I have text field label and near it I want to make drop-down list from wich I can select a book via it's label.
I want just to choice book from list which I put at my admin page.
I'm not sure that it should be mandatory filtering
i need help for making list of list:
A & M are two list:
im collecting some elements in A , and saving it in list M,
and where im clearing list A to collect new elements, my list M is also getting empty
M.append(A)
A.clear()```
So in my models.py I need to write filtering field?
Ok @late fjord I'll check it asap! Hope it'll help me!
just watch the video but the drop down menu you need to use javascript I guess, and I can't help on that
I don't know how to use javascript
hhh
Yes @@elfin bluff
I want to use it at my home page. So I working now on library site. I have author, genre and book. And I want to implement near textfield label drop-down list of books which I have at my database(I put them at admin page)
Can someone help me. I am using vscode and it always tells me I have 'unresolved import' problems when I dont. For example, "from wtforms import <whatever>" always gets the red squigily underline. In the problems section of VScode it says unresolved import. However the modules are installed and the import is working correctly at runtime.
I've had this problem too
(ignore that this is about pylint specifically)
Thank You @lofty matrix
help
File "C:\Users\wattow24\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
response = get_response(request)
File "C:\Users\wattow24\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:\Users\wattow24\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\wattow24\Desktop\programming\python\PyWeb\main\views.py", line 24, in create
return HttpResponseRedirect("/%i" %t.id)
Exception Type: UnboundLocalError at /create/
Exception Value: local variable 't' referenced before assignment```
code:
from django.shortcuts import render
from django.http import HttpResponse, HttpResponseRedirect
from .models import ToDoList, Item
from .forms import CreateNewList
def index(response, id):
ls = ToDoList.objects.get(id=id)
return render(response, "main/list.html", {"ls": ls})
def home(response):
return render(response, "main/home.html", {})
def create(response):
if response.method == "POST":
form = CreateNewList(response.POST)
if form.is_valid():
n = form.cleaned_data["name"]
t = ToDoList(name=n)
t.save()
return HttpResponseRedirect("/%i" %t.id)
else:
form = CreateNewList()
return render(response, "main/create.html", {"form": form})
Hello! Which web framework is better? Django or flask?
For flask sessions, when the user reopens the website does their session reload?
@native tide not always
Usually sessions stay until X amount of time or the browser's cache and cookies are cleared
Gotcha. I'm just having issues keeping a user logged in across the website's pages. I've been using Flask-Login for it so far and I'm just wondering why it's not working as it should.
>>> x = User.query.filter_by(email='example').all()
>>> x
[<User 1>]
I'm using SQLAlchemy. Is there any way to make the query show me the actual information of User1, such as email, password within the terminal?
your result set is a list, so you should access the item in your list. like x[0].email
Thank you very much! @glass walrus I understand! The .all() gives a list as there may be more than one. Thank you.
Question
i want to get into backend web dev...
I was getting used to using my frontend knowledge and moved over to webflow, but i want backend now so i can go full stack...
but i have no idea where i can host... any suggestions?
You can try to deply to Heroku
Though I'm trying it now for the first time and having a trouble lol
is there a limit on free heroku?
pretty much fresh out of school, but i'd like to start a lil thing of sorts
It great for fast deployment of small apps for free
It has some premium services too, though never tried
A matter of practice
Noted... thanks 👍🏿
Speaking of Heroku, I'm trying to deploy my app too, it uses gunicorn and flask. I came across a problem I can't seem to fix.
When I run the app locally it works fine.
But when I try to load it up in the dyno, it crashes
It doesn't seem to find the main package I have called "app"
Let me send an image of the file system
@burnt night If you signup to github student you get some sort of heroku subscription
Think it's something like a years hosting
This is my Procfile
When I tail the dyno I see that
Which is that import line
Any idea why it fails to find the app package inside the dyno?
@burnt night If you signup to github student you get some sort of heroku subscription
@native tide :o
thx
@burnt night link herehttps://education.github.com/pack
can someone spend time on private message with me on what i need use to create a website and what coding i need to do
i am a beginner
Im trying to download this image using requests but im getting 404 even though I used user agent(header), is the problem from my pc or its just protected from the website
note: if you see there's no network activities
@royal oak If you want to learn about web development and you're interested in flask here's a good book
Also I found codecademy's course with flask a good explainer for the most part
whats flask ??
A web development framework
oh okay so flask is were i do my coding ?
No, you code with Python. It gives you functionalities for web development. I'd suggest you read into it yourself
okay thanks
does anyone know why I am getting permission error ?
Is it possible to have my Django views change daily by replacing the current info in my view with info randomly selected from my database? I.e each night at midnight, I want to select a new object from the database and place its information in my Django view.
Here's a stack over flow question that might clarify what I mean: https://stackoverflow.com/questions/63328357/how-do-i-change-a-django-view-to-display-a-different-model-element-each-day
templates™️
How do I get query parameters with FlaskAPI? I figured out path variables, but I'd like to use a query param
I'm also open to suggestions for REST api libraries
If you have something against FlaskAPI
(I usually use Go for REST stuff)
@thorny dock
from flask import request
e.g url = "xyz.com/bob?name=jim&age=123"
name = request.args.get("name")
age = request.args.get("age")```
Flask is a really stable framework and incredibly user friendly, its certainly not the fastest tho if you're aiming for speed then flask isnt your thing, but overall flask is very powerfull
I prefer Flask over Django for example due to Flask's relative simplicity.
I'm not building a full backend with it, just a JWT microservice, so speed would be preferable. I only have two endpoints, /issue and /verify
hi not relate to python but I was wondering if anyone can tell me what type of image this call?
Svg?
Pretty sure 'offical' name for them are vectorgraphs
Example
Hi im kind of new in web development and i having a problem... im creating posts but when i put the second one it dont go under the first it apppear overlapping my first and i dont know why... can someone help me?
@weak lynx check your css, that's literally the only thing it could be
i will send it... @mellow tide
.review1 {
position: absolute;
margin-left: 134px;
margin-right: 250px ;
margin-top: 45px;
border-style: solid;
border-color: rgb(0, 0, 0);
border-width: 2px ;
padding: 30px;
padding-right:270px;
padding-top: 15px;
font-size: 17px;
}
How can i create a exact same of those under the first and then under the second...
Don't try to do it yourself, there are plenty of frameworks that do it for you. See "bootstrap"
Honestly, if you don't learn the frameworks that are out and about, you will be at a disadvantage in job hunts
And usually I'm a stickler for "learning the basics", but frontend web is very framework-centric
You definitely don't want position: absolute @weak lynx
If this is a div and you're stacking them one right after another, they'll default to being the way you really want them. No position needed at all unless you're doing something I can't imagine at the moment.
@warm igloo Yes thanks, i delete it and it works... now i have a little problem with some images but i will fixed it
thanks
@tight grotto I'd say you send us a traceback of the error..we don't know what "doesn't work"
Is Flask a good fit in the microservices architecture? I've seen plenty of people and frameworks relying more on Java rather than Python and this makes me reconsider whether I should keep going with Flask. From your perspective, is an online-store built upon a microservices foundation achievable with Flask as a micro web framework?
@native tide I think it depends more on how you implement your microservice architecture. As far as web/HTTP backend framework per se, you can probably be as lightweight as Flask even with Java, but I have no experience on the latter. If you're familiar with python you're probably better off with Flask, which is not bad at all for most web applications.
Python is no longer suitable for Web Development
i say this after 4 years in DJango and 2 years in flask
the documentation is now starting to drift behind as i see a lot of these projects being updated maybe one or two times a month
Node is absolutely ungulfing the web development world, and a lot more projects in Go and Rust are on its way
Also, in terms of performance, Python is extremely slow
spinning up a $5 general server on Digital ocean and puting a Flask-SQLAlchemy / Marshmallow project on will only give me a benchmark of maximum ~500req/s
just simplying returning a small json body
node can easily do 2k
per second
rust and go
even more so
2010-2017 was RoR vs Python. now its node and performance languages
The diffrence is Node acts as a async type system
If you actually Ran Flask with gevent like most people using it for APIs you'd find a very large increase in performance
even if that was the case, performance in go, rust, scala. or even in older lanaguages like Java or C++ in unreachable for Python
yes because theyre compiled
but people dont care about performance they care about how quick it is to develop and train people on
yeah, my team made the decision today to switch to Go / Node to keep up with the times
we're sunsetting all our Flask apps
which arelike 4 of them
look up uvloop, if you're squeezing for performance
uvloop doesnt work with flask
NOde is easier to teach than Python nowdays
the issue is they're comparing one of the slowest frameworks to a async node system
There is way more updated documentaiton on Node than Python
that's your opinion
I think its quantifiable
your claims are very questionable tho lol
I mean, it's pretty obvious that Node would engulf the world in web development - One language for the entire stack
i understand python is not natively meant for perfpython is very mature, the docs are very clear and concise, very easy to pick up
i mean no, Node has been around long enough to show itself
one of the biggest issues my team had with python was how difficult it was to use package managers
🤔 Then your setup must be rather scuffed
we used pip originally and we liked that, but were suggested to change to pipenv in which hell broke lose for us
reverted back to pip, and then ended back up on poetry
Currently, we dont find the python ecosystem sustainable, and find node and go's way more productive in the long run
can't complain about node, although the npm/modules ecosystem, yikes
wait... Do you just.... deploy without any containers or any decent organisation
yeah we're pretty small, we're not really dealing with docker or terraform
we have 5 microservices that we handle
and yet you have a go at flask for being slow lol
im sorry?
go is nice for microservices ngl
go is pretty nice
containerization will not help improve speed and performance
no but running flask with gevent would massively increase performance
not that it matters considering the system is normally slowed down by other systems but if you really want performance you'd use a ASGI instead of WSGI
yeah we're using uwsgi
we have looked at other frameworks such as starlette and falcon
but the development and environment just doesn't seem there for us
it was very questionable where these projects would end up in 2-3 years
we just had to go with Node in terms of this
i mean they've already existed for longer than that
node's security for the future is just that much greater
🤔 Even tho most npm modules arent maintained after a year
🤷 you do you ig
if you wanted speed so bad you might aswell run with Go over node in that case
yeah Go is needed for our websocket servers
just just use Go for all of it lol
node will handle most of the auth and just general routes
well, its not necessary, our devs are already working on node
god bless npm
lol
npm is a meme lol
if you're using webpack, you're using this package 🙂
seriously?
:), that's why i think this ecosystem is a joke
over half the JS community have no idea what they're doing
well, this is just a one off situation, but definitely a questionable choice by webpack
in general, js seems to be alive
so is python lol
i am feeling the death of python unfortunately
Uhm
im getting so many outdated SO stuff
🤔 Then update your modules lol
oh yeah mb
Answered 2 Years Ago
but why do you even use Stack overflow
you should atleast be beyond needing to SO everything instead of actually reading the docs
yeah that's the thing, Flask-SQLAlchemy and tying CElery together doesn't have docs
i have to rely on SO answers
well 3rd party integration is a different subject then native python libs
that's the responsobility of the lib owners
well, not really a responsibility
it's open source 🤷♂️
stack overflow question that i recently had to spend
20+ hours on
no joke
actually 20 hours is exaggerating
numerous hours*
I cant comment on that because i dont use Flask generally
also not a very mature package
df is celery even
celery helps with async operations
that's not distinct for python though, if you need some specific use case, you'll likely find a not-that greatly supported lib for it
celery is basically a queue of workers for handling processing
You went with Celery over a mature lib like Gevent or pyuv?
There is way more updated documentaiton on Node than Python
Lmfao. stop.please. Just one week I spent trying to solve an interview question and there was barely anything on the web. Lol
@bronze quarry
or some type green threads - can't recollect
according to their description its a Queue system
if you have an expensive task to run and don't want to block the main thread
you use Celery
we use it to set off timers in our system
actually uses rabbitmq/redis for the queue itself
yeah redis
basically it's a distributed task framework
they're essentially trying to act like a async framework
essentially, sure
async, parallel, concurrent, distributed
these are different things
well, async is basically a sub category of concurrency
async is just the blanket coverting of parallel and concurrent
yes but they're both used to create asynchronous systems
true
@quick cargo How could you use selenium to click a checkbox if the checkbox doesn't have an ID
@native tide css selectors?
er what does that mean @native pasture
Node docs are amazingly bad
tbh, node and python docs are preety good, i don't get what's with the language circlejerk
@native tide Google selenium css selectors and you'll find what you need
@native tide Google selenium css selectors and you'll find what you need
@native pasture Is there an ID for every single checkbox
It's just a checkbox of an official website, may I dm you it and you find out the ID?
Node docs have been woefully inept for me in the past. ArrayBuffer stuff specifically caused me a bunch of problems from lack of clarity
and in general, I feel like the Node ecosystem has much worse docs
Ive never been very interested in learning the Node eco system
seems pretty pointless to me
well - Node is great for going from 0 to something quickly
and the speed of it is relevant sometimes
If really want speed id go with Go or Rust depending on the level required
Do you guys know of any resource/book that builds a simple python microservice (preferably with Flask) together with a load balancer and service registry? I m trying to migrate an old project (from scratch since it's easier) to use microservices, I know the building blocks and frameworks I should use but I can't figure out how to glue them together.
Node gives a good compromise between speed of code and speed of development
hi
I'm wondering if It would be possible to set up a temporary web server using flask that would be accessible by other computers (not on my wifi [in fact, in another continent])
in my Flask API
im listening to a 3rd party post request
i can't seem to get the post body in json
POST /webhook/ HTTP/1.1
Connection: close
Host: 127.0.0.1
Content-Length: 346
Content-Type: application/x-www-form-urlencoded
id="W_79pJDk"
&collection_id="599"
&paid="true"
&state="paid"
&amount="200"
&paid_amount="0"
&due_at="2020-12-31"
&email="api@billplz.com"
&mobile="+60112223333"
&name="MICHAEL API"
&url="http://billplz.dev/bills/W_79pJDk"
&paid_at="2015-03-09 16:23:59 +0800"
&x_signature="f0ff6c564f98d5403e2b26fbd3d45309c76eb68d8c5bcda0d48b541c3502a396"
Body formatted for readability.
heres how the post reqest looks like
i've tried request.get_json(), request.form.keys(), request.get_data()
@app.route('/api/billplz_callback', methods=['POST'])
def billplz_callback():
data = request.get_json(force=True)
print("from billplz: ")
pp.pprint(data)
return 'hello'
this returns None
the API isn't sending you JSON, when you're trying to read JSON
take a look here and try these suggestions https://stackoverflow.com/a/16664376/8015233
guys do you know any good tutorial to learn django?
@cloud path https://www.youtube.com/watch?v=UmljXZIypDc&list=PL-osiE80TeTtoQCKZ03TU5fNfx2UY6U4p Best one there is IMO
In this Python Django Tutorial, we will be learning how to get started using the Django framework. We will install the necessary packages and get a basic application running in our browser. Let's get started...
The code for this series can be found at:
https://github.com/Core...
thanks
My django project dir looks like this
from my views.py file i am trying to import
view.py looks like this
from django.shortcuts import render, redirect, reverse
from django.http import HttpResponseRedirect
from .models import Subscribe
from django.core.mail import send_mail
from django.conf import settings
from .forms import SubscribeForm
def foo():
return 'foooooooo'
# Create your views here.
def home(request):
context = {'text': 'Thanks for Subbing'}
return render(request, 'subscribe/home.html', context)
def index(request):
if request.method == 'POST':
subscribe_form = SubscribeForm(request.POST)
if subscribe_form.is_valid():
subscription = Subscribe(
name=subscribe_form.cleaned_data['name'],
email=subscribe_form.cleaned_data['email'],
send_gap=subscribe_form.cleaned_data['send_gap'],
country=subscribe_form.cleaned_data['country']
)
send_mail('subject', 'this is a message', 'testkenny00@gmail.com', [subscription.email],
fail_silently=False)
subscription.save()
return redirect('home')
else:
subscribe_form = SubscribeForm()
context = {'form': subscribe_form}
return render(request, 'subscribe/index.html', context=context)
when it reaches the line from .models import Subscribe
i get this error
ImportError: attempted relative import with no known parent package
but i am not running the views.py file but send_every.py
send_every.py looks like this
from apscheduler.schedulers.blocking import BlockingScheduler
from views import foo
sched = BlockingScheduler()
# Schedule job_function to be called every two hours
sched.add_job(foo, 'interval', seconds=30)
sched.start()```
how do i fix this?
from models import Subscribe@native tide
I have been using Linux today I installed windows I tried to run python manage.py runserver but I get nothing back anyhelp?
python3
same prob
open a terminal and type python --version, python3 --version
see what version it throws
just type python and see if the shell opens
python3?
hello @everyone
what linux distro?
I've started learning flask + socketIO to create webservers. Me and a friend are trying to do a thing, but we are... far to say the least (like halfway across the world). I created a webserver hosted on my public ip address, but he couldn't connect to it. The server did show evidence of him trying to connect, but it would always time out. Is it possible for people this far apart to connect with a url with an ip address, and if it is, what are we doing wrong?
i am facing an issue with django i have 3 apps in my django project and i can't manage to access templates from the store app
I installed iit from Microsoft store it works now
thanks
the tree
@coral raven the pc think I don't have it at all
the error i got
u don't have store.html
@short sierra yes i do as you can see in the tree
but if i use urlpatterns = [
path('store', views.store, name='blog-store'),
]
instead of urlpatterns = [
path('store', views.store, name='store-store'),
]
it works
@nova sleet About that if you are running a local host, your friend cannot connect to it. You can use ngrok to make a temporary server to which he can connect
@short sierra any idead how to handel it ?
It wasn't 127.0.0.1 if that's local host. It was my public ip, but I'll look into ngrok @coral raven
setting up ngrok is easy
pip install pyngrok
then once you have your server running
open a new terminal and type ngrok [port_number_where_server_is_running]
It will spit out a weblink
If you close the terminal the server will close
@nova sleet
oh
that seems really easy
so quick q
would local host be ok in this case, when initially starting the server, or does it have to be my public ip?
yes local host is fine
okely dokes
also you can see all the requests in the new terminal you made
downloading pyngrok failed
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
was the final error
@coral raven
Wait let me see
@nova sleet
one correction its ngrok http [port_number]
how to convert doc to pdf in python on linux??
hey any flask ppl here? ping or DM me?
Thank You!!
Asking good questions will yield a much higher chance of a quick response:
• Don't ask to ask your question, just go ahead and tell us your problem.
• Don't ask if anyone is knowledgeable in some area, filtering serves no purpose.
• Try to solve the problem on your own first, we're not going to write code for you.
• Show us the code you've tried and any errors or unexpected results it's giving.
• Be patient while we're helping you.
You can find a much more detailed explanation on our website.
shall i DM u?
@indigo kettle No. See point 2 above, and if you need help beyond general discussion see #❓|how-to-get-help
alright sry!!
No problem.
Hello everyone. Can someone explain me how to make my buttons in html work with flask. Basically I made a button that should redirect me to another template of mine and just doesnt.
from flask import Flask, render_template, request, json
app = Flask(__name__)
@app.route("/main.html")
def naslovnica():
return render_template('main.html')
@app.route("/o%20timu")
def onama():
return render_template('o timu.html')
if __name__ == "__main__":
app.run(debug=True, host="0.0.0.0", port = 80)```
this is the code
your template would matter more, unless it's a python error you see
It's not a python error. When I click the button I get like error web page instead of my redirected web page
I mean, I dont get any errors in the console...
i'm kind of new, but i can't get my website to locate my css file
@native tide Make sure your css file's location is correct.
You need to have this line in your <head>
<link rel="stylesheet" href="styles.css">
But change style.css into your file's location.
Hello, I hope that I am asking within the correct channel but I have an enquiry which I haven't really had an sound response:
I am looking to develop a personal blog website using python. I am not sure if I should be doing this in Django or Flask?
I am of a beginner with Python and python is the first programing language I have learned. Would anyone be able to provide me with some good advice? I would really appreciate any response. Thanks.
@warm wren Django has everything you could possibly need built in, but it's a steeper learning curve ... flask is easier to learn, but you have to bolt everything together yourself with libraries.
Building a blog site in django would require more upfront investment to get the site set up as django is more complicated than flask.
Building a blog site in flask would be simpler, but you will end up writing more and more features by hand to manage things as you want to add more features.
If you're very new to Python, it might be a good idea to use flask as it is simpler to understand and will require less effort to get something very basic working. I'd recommend using something like heroku to host your blog since it's simple to get started and you won't have to worry about managing a server.
Hey guys
So, I just knew scraping site like this is illegal https://www.whoscored.com/Statistics but I want to learn web scraping with a website that has pagination but without different urls. How can I do that?
If you want to learn how to scrape a paginated site, why not create a test site that has pagination? At least that way you can learn how to deal with the different methods of pagination (scroll IDs, offsets, counts, etc.)
@frank vine Thank you so much for your response! I really appreciate it.
@mellow tide Also thank you!
If you want to learn how to scrape a paginated site, why not create a test site that has pagination? At least that way you can learn how to deal with the different methods of pagination (scroll IDs, offsets, counts, etc.)
@frank vine create a test site? No way. Firstly, I don't have time to do that. Secondly, I won't manage to create such stuff
Hey guys!
I'm with a little problem:
i want to use the value from an html select field in an url,
like foo.com/25 where 25 is the size
how to do it using an select field?
I need jquery?
@native tide
import json
import os
import sqlite3
from flask import Flask, request
fruit = [
'apples', 'bananas', 'cherries', 'damsons', 'figs',
'grapes', 'kiwis','limes', 'plums'
]
if not os.path.exists('fruit.sql'):
with sqlite3.connect('fruit.sql') as db:
db.execute("""CREATE TABLE IF NOT EXISTS fruits (
name text
)""")
db.executemany("INSERT INTO fruits (name) VALUES (?)",
[(x, ) for x in fruit])
db.commit()
app = Flask(__name__)
@app.route('/')
def page():
offset = request.args.get('offset', 0)
count = request.args.get('count', 2)
with sqlite3.connect('fruit.sql') as db:
cur = db.cursor()
cur.execute("SELECT * FROM fruits LIMIT ? OFFSET ?", (count, offset))
response = cur.fetchall()
return json.dumps(response)
app.run()
There is a super naive implementation of an offset-count paginator. You can use that to learn how to scrape that kind of paginated sites. There are more sensible ways of doing this (this implementation has no input sanitisation or use models in, say, sqlalchemy which comes with better pagination logic) but this is sufficient to learn. It took me about 10 minutes of fiddling around. I'd really recommend you practice writing these little bits of code so that you can make these little experimental programs; it's really beneficial.
Hey, what do you all guys think is better for productivity and small-medium sized teams: a real time chat app like slack or a threaded chat like twist?
Hi! I hope you all are good... can someone say me the best hosting free?
I mean you just listed a Programming lanuge a micro framework and a full framework
idrk what you want us to say about the entire language of js lol
Hey does anyone know how to prevent passenger_wsgi from getting overwritten?
I am dealing with Namecheap hosting and almost every time I do git pull it changes my passenger_wsgi gets overwritten back to
import imp
import os
import sys
sys.path.insert(0, os.path.dirname(__file__))
wsgi = imp.load_source('wsgi', 'app.py')
application = wsgi.application```
Which is very annoying because even if I change my application name to app.py and put it on the same directory as the passenger_wsgi.py it still doesnt work
I always have to change it back to
import os
import sys
sys.path.insert(0, os.path.dirname(__file__))
# noinspection PyUnresolvedReferences
from main import app as application
almost every time I do git pull
To be clear, the passanger on my repository is the correct one, but for some reason when I restart the python app with the button on cPanel, it gets overwritten by the first default one which doesnt work at all
I've posted a Django question in #help-chestnut if anyone is free to help :)
How can i call a function from flask?
Hello, im just learning to use django, im absolutely new to web development and i'd like to learn a bit of html to complement.
can you recommend me some good place to learn?
https://github.com/django/django/blob/f4ac167119e8897c398527c392ed117326496652/django/db/models/query.py#L563 am I mistaken in thinking this method has a TOCTOU?
I've only had to make one once for a Flask app, @weak lynx
What is yours supposed to run?
For instance, my Procfile is a single line:
web: gunicorn wsgi:app
**I'm getting an error in visual studio code where it says
Unable to import 'django.urls'pylint(import-error)**
guys, sorry if i'm interrupting, i tried in stack overflow and other sources, but i'm not finding how to
i want to pass my model data to javascript inside flask application
like
entry = {
id = object.id,
title = object.title}
how can i do it?
i tried {{object.id}} but had no success,
@wild thunder do this
final_graph_data = JSON.parse({{final_graph_data | tojson}})
{% endblock %}```
and on the server side
pass this in render_template final_graph_data=json.dumps(final_graph_data)
so, it would be like:
{% block javascript %}
object = JSON.parse({{ object | tojson}})
{% endblock %}
?
yes yes, but remeber to make it json on the server side , that I wrote beneath that @wild thunder
alright
i'll do
one sec
got this :
TypeError: Object of type Product is not JSON serializable
it's an SQLAlchemy Model
class Product(db.Model):
etc
do i need to create an @property with the data i want to send?
see anyhow create a dict data str on the server side do a json.dumps there and send it via render_template and then do a json.parse . That's it
@wild thunder
i'm on it
1 minute
well it kinda worked
but do i need to use all that {% jinja lingoo%}
all the time?
or just the json.parse
well after parsew now you have javascript object now you can do anything with that
@wild thunder
i mean, i want to send it to my serverside
after data manipulation send data to server side via any api call lib, like if you're using jquey then it is $post or $ajax or if you're using vanilla js then there is simple request library
oh
@wild thunder google it it's easy, I am out now
i was mistaken, i'm sorry
i was putting my {% javascript block %} out of an js tag
it was rendering it in the page instead of keeping it in the background
put that above <script> tag

but now
var entry = {
titulo: produto_json.titulo,
moldura: second_box,
id: produto_json.id,
price: price}
i want to send it to serverside
and i'm getting method not allowed
my route is 'post' only
anyone used scrapy for web scraping and can comment on whether it is worthwhile versus simply writing one's own web scraper with say, requests and beautiful soup?
I am using pycharm for my IDE. I am also using django. I changed my css code but it is not changing on the site. I even deleted everything in the css file and it still is not registering that i deleted it on the website. I ran the server and went to the link, and pressed view page source and located my css file, and it says i still have all of my old css stuff on it, but i changed it, it's just not registering.
I am using pycharm for my IDE. I am also using django. I changed my css code but it is not changing on the site. I even deleted everything in the css file and it still is not registering that i deleted it on the website. I ran the server and went to the link, and pressed view page source and located my css file, and it says i still have all of my old css stuff on it, but i changed it, it's just not registering.
@native tide can i have a look at your code? did you add it to static?
in settings.py?
also get a help-channel 😗
Please help me with this issue, trying this whole thing since 2 weeks but couldn't solve.
I've been learning Python for about 6months now. I'm trying to do more web stuff and feel like there is so much more support for javascript based setups rather than Python/Django. Instead of doubling down on Python and learning python, should I bite the bullet and head down a javascript/node etc track?
I've been learning Python for about 6months now. I'm trying to do more web stuff and feel like there is so much more support for javascript based setups rather than Python/Django. Instead of doubling down on Python and learning python, should I bite the bullet and head down a javascript/node etc track?
@spring jasper
well, JS is unparalleled for frontend stuff
but if you're talking about a backend API...Python is fine.
If you want to do web the modern way, then you need to do single page applications which require JS or something that transpiles to JS
and if you're doing the frontend in JS, NodeJS for the backend is fine - probably easier to jump into than a mix of python for the back/JS for the front
I'm having trouble implementing model constraints. If anyone can help, I've posted on Stack Overflow
Awesome thanks @vestal hound abd @rigid laurel
I am using django's built in method to reset the password for a user. I am getting this error. Can anyone help?
Hi im triying to deploy a flask and python web into heroku but its getting me H10 app crashed, can someone help me please??
How to use break in jinja 2
EMAIL_USE_TLS
@flint breach Oh, i found a typo in my code! Thanks
Why is it not working when i make a new python file in my app folder and try to import for example models in that file
FOR EXAMPLE
my dir looks like this
I want to import a model from the models file in fill_database.py
but i get this error django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
the fill_database file is this
from models import ArticleWord
from scrape_words import all_words
for word in all_words:
a = ArticleWord(word=word.word, article=word.article)
a.save()
what is the purpose of this file?
basically, django imporrts all the files you have, and executes them, you're iterating over all your "words" and then creating an object, when the django hasn't done the startup process yet
i don't know what you mean
Are you trying to run the file fill_database.py directly ?
That's what the error is suggesting
yes i am runnung fill_database
guys, good morning
I'm already losing my mind, on at least 3 stackoverflow questions i got my "answer" but this s*** is still not working.
i'm starting with js now, had no prior experience at it
i'm trying to get the value from a select field
i'm like 8 hours trying this and had no sucess, the only way i manage to do it is passing the function with (this) inside, but i don't want to get the value just interacting with it
can anybody help me?
document.getElementById("your_select_id").value
Ok, do
console.log(document.getElementById("your_select_id"))
console.log(document.getElementById("your_select_id").value)
please
Are you trying to get the text or the 'value'? In a select field, they're different
its returning undefined
First one or second one ?
1 sec
i'll try that snipp
i'm using flaskforms
{{ checkout.tamanho(class="form-control", id="SizeList", required='required' ,type="text", onchange="getSize(this)") }}
<div class="row left-10" id="SizeList">
<b>
<p class="tamanhos">A4</p>
</b>
<b>
<p class="tamanhos">A3</p>
</b>
<b>
<p class="tamanhos">A2</p>
</b>
</div>
it was returned by that console.log(document.getElementById("your_select_id"))
The second one I guess ? As you can see that's not a select, just a div and some bold paragraphs
oh, jesus
i guess i found
the error
i'll check
fml
sorry guys, found the error
somehow i had a div with the exact same name and it was not pointing to double id names
i'll keep that in mind, thank you @bleak bobcat
now i'll get my breakfast, i would not eat without solving this
Hello all. Any recommendations for a tutorial/course for a beginner who wants to study HTML CSS JavaScript
@atomic zinc are you a complete beginner
Codecademy
@livid scaffold yes
https://youtu.be/gQojMIhELvM I have seen this recommend but it's from 2018
Learn Web Dev the way professionals do! This FULL course covers it all. We'll learn HTML, CSS, Javascript and the workspace/computer setup that professionals use.
IMPORTANT! If you ONLY want a website for yourself or your business, DO NOT learn all this stuff...it's a waste ...
Got got an email confirmation functionality done with Flask... this is awesome
Great!
In this short HTML tutorial, I explain the basic structure of an HTML webpage and introduce some important tags.
Support this channel at https://www.patreon.com/jakewright
Ready to learn some more advanced HTML? Move on to Learn More HTML in 12 Minutes
http://youtu.be/KJ13lX...
I introduce CSS, explain how to link a CSS file with an HTML document and teach the syntax of the language along with the most common properties.
Support this channel at https://www.patreon.com/jakewright
----------- More tutorials -----------
Learn HTML in 12 Minutes: http...
thanks
these are basic
You will learn some more essential HTML tags along with some attributes that can be used to give the tags extra properties. After watching both videos (part 1 and this one), you will know enough HTML to make a website. You can then look into CSS to add style to your website.
...
<a href='/verify_account/{{ token }}'> Click here to verify </a>```
How can I set the <a> link to the /verify_account/<token> route I have in flask?
Nevermind - I got it. Here's for anyone who's interested:
<a href={{ url_for('verify_account', token=token) }} > Click here to verify </a>
But I do have a problem.
Say I was in gmail, and I pressed the link, it would send me to /verify_account/{{token}}/ I'm currently running on localhost, and the link doesn't include it (so it doesn't work).
Is there any way for it to redirect to http://127.0.0.1:5000/verify_account/{{token}}/
Can I ask about javascript here?
@glossy arrow You can, but there is no guarentee you will get an answer considering this is a Python server
Ok, thanks
Learning Django...
I have a form that I have submitted data through from my index.html. I want the results of the form to show up on my result.html. As of right now, everything shows up right including the checkboxes I checked from my form... everything except my radio buttons. They show up, but they show up with the name rather than the value.
<div id="married_block">
<p>Married?</p>
<input
type="radio"
id="married_yes"
name="married"
value="Yes"
/>
<label for="married_yes">Yes</label><br />
<input
type="radio"
id="married_no"
name="married"
value="No"
/>
<label for="married_no">No</label><br />
How do I get the result.html to show Yes or No instead of married or child?
EDIT: Turns out there was absolutely nothing wrong... when in doubt: restart server.py, refresh browser
result.html:
<p>Married: {{married}}</p>
<p>Children: {{child}}</p>
user_form_married = request.POST['married']
user_form_child = request.POST['child']
views.py
def create(request):
if request==Post:
form =NewPost(request.POST or None)
if form.is_valid():
form.save()
return redirect('homepage')
else:
form=NewPost()
return render(request,'blog/create.html',{'form':form}) ```
``` forms.py ```
class NewPost(forms.Form):
title=forms.CharField(label='Your name',max_length=50 )
content=forms.CharField(label='Your name',max_length=300) ```
its not working anyhelp
I want to be able to make dashboard for a discord.py bot, but I can't find any templates or whatever. What is a good suggestion?
What is the best way to make html fully responsive on mobile devices using css?
@craggy orchid I created my own using React, any JS framework could get this set up very quickly. If you just want a static sort, you can google "free dashboard templates" and should get a nice selection
Ok
@elfin gyro I often use bootstrap since it handles quite a lot of the responsiveness. Other than that, I like to take the "mobile first" approach. This is designing a site with mobile in mind, then making it work for desktop, not the other way around.
With that said, if designed well, it can take just a few media queries to make it work.
I'll send a picture of what a REALLY particular component required for css to work on desktop
this needs to be refactored, but this is the solution I needed to get a really particular banner to work on multiple devices
I would say the best way is to keep it simple, design with mobile in mind, then alter things where needed in media queries. If using a framework, the mobile side can be an after thought (although it should not be) if you are able to fit everything into the framework.
i.e for bootstrap
<div class="container-fluid">
<div class="row">
<div class="col">
<h1>Stuff</h1>
</div>
<div class="col">
<h1>More Stuff</h1>
</div>
</div>
</div>
hey guys
in flask
im trying to do a thing where
the user uploads a csv
i manipulate it
and then the user can download the manipulated csv
any idea on how to do this?
How can I make form ( or some text box) bigger? IM working in flask and I want to see more links when I paste them
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<h1>Hello template</h1>
</head>
<body>
<form method="GET">
<input name="text">
<input type="submit">
</form>
</body>
</html>
def here(sometexthere,templatehere):
@app.route(sometexthere)
return render_template(templatehere)
Why does this give me Invalid syntax.
I'm using flask.
@app.route(sometexthere) above def
ok thanks
Anyone using FastAPI in production by chance?
@crimson yarrow so are you asking us to write this app for you? do you have code?
yeah i have some code ill post it
short answer is yes you can do that
i was more asking like a higher level overview of methodology
what i have going on right now it
an ajax for the download button
that sends to the flask back end the uploaded file
and in the back end the processing is done
yall ever have the query ID and session ID differ ? how strange
wow ... i haven't heard the term "ajax" in a few years lol
$('#dld').click(function (e) {
e.preventDefault()
$.ajax({
type: 'POST',
url: '/raw_data_download',
data: new FormData($('#upload-file-form')[0]),
contentType: false,
processData: false,
success: function (data) {
console.log(data)
}
});
});
mostly because almost everyone hate XML
@app.route("/raw_data_download", methods=['GET', 'POST'])
def raw_data_download():
all_files = request.files.getlist('csvfile')
raw_df = pd.concat((pd.read_csv(f) for f in all_files))
raw_df = raw_df.drop_duplicates()
return send_file(raw_df.to_csv(),
mimetype='text/csv',
attachment_filename='Adjacency.csv',
as_attachment=True)
oh rly?
i thoguth everyone uses jquery
but yeah i just wanna basically send that raw_data as a csv file to the user
i can't speak for everyone, but in every job i've ever had, all the messaging is in JSON
like a download prompt
yeah
if i could maybe turn the csv into a json
and prompt a download
basically i just want them to be able to download that raw_df
so, any time i've ever done that, it required a place to put the processed file (S3 bucket, or static asset place in my local web server) that I then point to ... i've not done a pure stream of a CSV or anything for that matter
How can I have a variable in a function transfer to another in flask
Ajax doesnt really mean xml
How can I have a variable in a function transfer to another in flask
you can pass it as an argument, or find a different way to do it haha
Is there something i can use that can make making a forum website easier?
That's Python not that I know of.
If you really wanted to in Python could just use Django and that would be fast af to make it.
else I would use MyBB or something along those lines
Am using flask and html css for front end.
django is kind of made for forum/blog style sites. I feel that your question is a little too vague
To make things easier: use a css framework.
Follow tutorials. Django is set up out of the box to make a forum/blog site
I already started with flask, am finishing up the home page and i need to know how to make forums.
@acoustic oyster
yeah, I understand I do not use flask.
Do you have a more specific question though?
if you just want to create an entire forum, the I recommend following a tutorial
Is there something that is built upon flask that i can use to make forums easily?
Their default tutorial covers a blog site, which is very similar to a forum. I believe you would need to add some custom stuff for replies and what-not, but this is a good start.
creating a post would be the first step.
I would consider adding replies/comments to be the next/more advanced step in working with flask
Ok thanks.
You could look at Corey Schafer as well for Flask tutorials.
Not exactly like a blog. It does have login, logout and posting features for all users though. Series is here: https://www.youtube.com/watch?v=MwZwr5Tvyxo&list=PL-osiE80TeTs4UjLw5MM6OjgkjFeUxCYH
In this Python Flask Tutorial, we will be learning how to get started using the Flask framework. We will install the necessary packages and get a basic Hello World Application running in our browser. Let's get started...
The code for this series can be found at:
https://githu...
Ok thanks.
This is a really dumb question most likely, but i can't figure out how to make my stuff not resize all weird when i change the size of the window in chrome
like your html?
You would need to just set the size using css/style
i.e
<img class="my-image" src="this_image.jpg">
and in css
.my_image{
width: 300px;
}
something like this
@native tide
some Internet explorers allow the use of vw
so for example
if you would like the text to be the same size as you zoom in
you can do font-size: 3vw;
otherwise
just search up, Making my site responsive
hey guys, i wanted to deploy my django app using heroku (first time deploying a web app).. i looked at the documentation and watched a couple of videos, but some places say that i need AWS if i want to allow the users for uploading pictures. (it is a blog app).. what do ya'll suggest?
Where will the images be stored and/or hosted?
AFAIK heroku does not offer a block storage solution
i honestly dont know a lot, i thought i could do everything with heroku
I'm not an expert on Heroku but I'm pretty sure they don't offer block storage. You'll need somewhere to store your images and host them.
if you want to upload images you probz want something like S3
hmm.. so i cam store like blog posts on it?
hmm.. so i cam store like blog posts on it?
@normal blade you can use a database for that
Yes S3 would be AWS's block storage offering.
which Heroku does have
well
Heroku has Postgres too
oh greato
IMHO though if you're using AWS for S3, I'd probably architect the whole thing on AWS. Getting Heroku and S3 to authenticate will be no fun and it won't be nearly as performant as if everything is on AWS.
AWS has a managed DB offering too (Aurora)
hmm, does AWS have a free tier for students in Canada?
and it is much better at scale than heroku (although that may not be an issue)
AWS has a free tier for students, not sure about international restrictions
yup
it's basically a tradeoff between convenience and performance
like IMO (because that's what I'm doing now)
Yeah but I think hooking heroku into S3 means it's a tradeoff between performance and performance.
haha
AWS + Heroku is still more convenient than everything on AWS
Not to mention learning heroku is not very useful in an enterprise while AWS knowledge is very useful.
i was following the CoreyMS django tutorial haha, he does S3+heroku as one option
@vestal hound I disagree whole heartedly. AWS architecture can be simple. It is challenging to get to that architecture but there are plenty of resources in this server and elsewhere to help. Heroku+AWS will always be inconvenient.
Then again, I don't see a need for heroku/netlify/etc. for hobbyists unless you actively don't want to learn marketable skills.
AWS + Heroku in the sense of just S3
It starts with S3, there will be something else 🙂
wait so, if i just remove the pictures.. i can do everything with heroku?
Yes
and then shift to fully aws once i get aws credits from my uni?
You could still have images, just make it so users have to provide you a URL instead of allowing them to upload them.
huh, and heroku is free for a while eh?
I know little of heroku but yes I think so.
Again, if you're trying to learn AWS, why not just use AWS?
AWS has a free tier also
because, im so sure i will exceed the limits of aws
You will be working on this for over 750 hours in a month?
wait i thought that was per year lol
Even if you do, AWS is very cheap. My monthly bill for a number of hobby projects is about $1.50
750 hours per month of Linux, RHEL, or SLES t2.micro or t3.micro instance dependent on region
that noice
Just make sure you use the right instance size/type the UI will confirm that it's free
Basically 750 hours means it's free as long as you only have one instance. 30 days * 24 hours = 720 hours
uni has a incubator, i have applied.. if i get selected I'll receive a lot of aws credits (hopefully)
@vestal hound I disagree whole heartedly. AWS architecture can be simple. It is challenging to get to that architecture but there are plenty of resources in this server and elsewhere to help. Heroku+AWS will always be inconvenient.
@snow dragon it can be
but I don't really think the startup cost for AWS can be compared to that for Heroku
I just want to deploy stuff
dude thats pretty decent, does the aws cost scale exponentially? my uncle pays like 2700$ a month for his company
AWS is a marketable skill, especially creating simple, maintainable architectures.
@normal blade I wouldn't say it scales exponentially. A large part of your cost is how good your architects are...
hmm
@vestal hound I just think if someone is a young developer, looking to learn cloud deployment. Saying that heroku is "easier" is misleading. It's potentially not the best use of time.
oh well, mine gonna suck for sure lmao
it depends on what you're looking for.
you should tailor your level of abstraction to your needs.
Right,
looking to learn cloud deployment
But AWS has Lightsail, which is a very similar offering
Lightsail + RDS is the same level of abstraction as Heroku
aight guys, thanks a lot for the help! I’ll discuss with the “cofounders” about aws vs heroku xd.. appreciate it 🙂
indeed
No problem
everything Heroku has, AWS probably has, more or less
Seems like we could use a Cloud topic
my user experience has been a fair bit better with Heroku than AWS though
and right now it meets my needs
so
@vestal hound Yep. My point exactly. I'm not saying Heroku is worthless or that you should never use it. I actually work on a hobby project that uses it. But none of the devs involved are looking to learn cloud (we all know it) and we know that the scale will remain low. I just think it's the wrong answer for young devs trying to get cloud deployment on their resume.
I certainly +1 on the cloud topic needed. Though I guess devops kind of covers deployments ¯_(ツ)_/¯
None of my style.css files are loading in flask, how do i fix this
Flask doesn't load them, your html tells your browser where to get them from
If I had to guess, your html is grabbing them from the wrong spot or not at all
@ember kayak
what is the best way to create multiple user types in django?
Would you like me to show you?
@ember kayak run the site in flask and check the page source for the <link rel... that points to your css
Then?
Well first of all, make sure it looks right
Ok, want to get in a vc(inwont be able to talk) and show you my screen?
thank you ill look into it
No, sorry. My family is sleeping.
ctrl + f5
Me?
yup
Nothing happend
So if I had to guess, you aren't including the css as a thing that flask is actually serving (e.g. static assets)
Wdym?
Google flask static assets
You have to serve all of your site (css included) for it to work, so do some googling and when you get stuck, we can help further
Ok
@app.route('/cdn/path:filename')
def custom_static(filename):
return send_from_directory(app.config['CUSTOM_STATIC_PATH'], filename)
custom your path
Fwiw, hand feeding people solutions doesn't actually help them when they are learning
i see
Hello!!! Who have one job?
um, I have a job.
lol
😂 😂
Hi everyone, not sure if I am posting in the correct channel but I'm dealing with an issue with virtual environments in conda (working with Flask right now). When I activate my environment, there is no parenthesis on the left that indicates what environment I'm currently in. Does anyone know how to fix this?
hlo everyone i am new in this community and i need to design a web so plz tell me the process from beginning
???
@forest star learn HTML, learn css, learn js (optional)
what does it mean when i run py manage.py runserver
and see this Watching for file changes with StatReloader Performing system checks... the entire time.
views.py
def create(request):
if request==Post:
form =NewPost(request.POST or None)
if form.is_valid():
form.save()
return redirect('homepage')
else:
form=NewPost()
return render(request,'blog/create.html',{'form':form}) ```
``` forms.py ```
class NewPost(forms.Form):
title=forms.CharField(label='Your name',max_length=50 )
content=forms.CharField(label='Your name',max_length=300) ```
its not working anyhelp
With flask is there any way I can render a new template onto the page, without changing the URL?
@native tide it's the debug function
okey
@native tide depends
So could I have a render_template in an if statement?
Sure, why not
!close
Has anyone used bootstrap with WTF Forms
Can someone help? Im working with python and flask. I want my layout template to have a conditional that depends on the current url/route. for exampe, my layout template has tabs, and I want the tab that is for the current page to be a different color or 'active'. How can i do this?
@brave elbow Have a conditional for rendering it. Have a tag for it. for example in a dict use something like "current_page": "home"
and then on the Jinja template have {% if item["current_page"] == 'home' %}active class here{% endif %}
have it inside the class="{jina2stuffhere}"
Thank you very much!
You're welcome! Hope that helps
How can I serve a file of the disk using aiohttp.web?
@plucky holly I'm little confused. Did you call that function, like, anywhere in the code because I just can not see it...
Ok, do you get the program to print "Listening on localhost..."
@plucky holly
I mean, could you try it again and tell me? I mean if it doesn't I think what might be the problem but I am not an expert using web sockets...
Maybe host it on local network?
Just for testing.
Hey I am trying to learn about how to make a flask web application using sessions for login and I am really perplexed about how it is storing its data
For example I am currently using Flask_Discord to authenticate using Discord
When I first ran to program the scopes were configured so it would get my guilds data
Then I changed the scopes to only have my identity
But the Flask app still has my guilds data cached somewhere, and what is driving me nuts is that i have no idea where
This is the code I somewhat modified but started with
This is the code I somewhat modified but started with
So like in this part
If you leave the discord.create_session() empty the scope that Discord will ask automatically includes 'guilds'
After I ran it once and gave it that information I specified that I only wanted 'identity'
It still returns me this though when I access the guids section in the webserver
thanks!