#web-development
2 messages Β· Page 66 of 1
i was working on a async version of Django's orm for a bit
I like the orm i dont like how annoying it is to hack
exactly
I have some premade templates for most of my services
I used to write everything from scratch a while back
which resulted in many hours spent on reinventing the wheel
Im trying out aiohttp stuff more now lol
Hey friends. Quick question, I just installed Django via cmd after setting up they venv. However my question is:
Do I have to create a new venv for every new project?
Do I have to activate/deactivate the venv for lets say my Blog project everytime I restart the pc?
that depends
if you're running via cmd yes
but its pretty easy to make a simple batch strip to activate it
and its best practice to use a diffrent venv for diffrent projects
to help organise dependencies etc...
but no you dont have to
Alright thank you
has anyone implemented this in a flask app https://docs.sqlalchemy.org/en/13/core/custom_types.html#marshal-json-strings
I usually use marshmallow to serialize/deserialize models to json https://marshmallow.readthedocs.io/en/stable/
Is there a way to add a default value to a choicefield in a form in Django? I have a dict of countries with country codes, but I want to include an option that says "all countries" which is actually a null value (and therefore doesn't narrow anything down).
Hi
I'm trying to do the shopping cart section for a pizza restaurant
But I can't figure out how to add the products to the shopping cart
Does anyone know how should I get started
Btw I'm using django
Anyone familiar with the Eel library?
hello guys can anyone help me with selenium?
i really need a guy who can help me ?
i want to scroll down in my insta followers and following list using selenium
can someone help me with css?
i want to format an img and paragraph so they are side by side
but thye are in different divs
use display: flex;
@dusk spade wdym
<header>
<h1 class='title'><img src='mapleelectronics.ico' id='title-image' alt='Maple Electronics Logo'>Maple Electronics LLC</h1>
<div class="img-container"><img src='parts.png' alt='Parts'></div>
</header>
<main>
<div class='content'>
<p>Maple Electronics Established on January, 2006 and is located in the heart of Silicon Valley in the state of California.
Our highly trained and knowledgeable staff with more than 20 years of experience in electronic component sales are able
to supply the industry with hard-to-find components, surpluses, and generic products. We have access to an extensive,
high-quality inventory, and a worldwide database of obsolete, allocated, and hard-to-find electronic parts. We offer fast,
low cost, and high quality services.</p>
</div>
</main>
if you want two div's next to each other use the css display: flex in the parent
i wanna put parts.png and the paragraph side by side
so move the imge-container inside of content
then in your content class set display: flex
show me
sry abt the cmd
@dusk spade heres the pg norm
i want the pic and text side by side
can you post it on https://codepen.io
create a post on that site --^
share the link
it didn't saave
wdym
Β―_(γ)_/Β―
hey, im a beginner with python and a complete noob with Django. I was trying to run a project from github, I tried making a virtualenv but Im not exactly sure how this works. Would someone be able to help (or let me know if this is a bad question, oops!)
did you installed virtualenv?
@glossy crown
first you need to install it same as any package in python.. ```
pip install virtualenv
then path to the folder of your project by cd path
then create vritualenv by virtualenv virtualenv_name
in your project folder a folder created with the virtualenv name that you just created..
open the folder then scripts then copy path
past it on command line and add \activate at the end
virtualenv_name\Scripts\activate
can someone help me with selenium>
is there a good tool that lets me pause a http request before following redirects?
We have some actual sane Url routing now
Class views appear to be alot more weird
what framework are you using?
aiohttp @twilit zenith
hello, can someone help me with flask, i try to print the username and password form data
what about it
can i private msg you?
@native tide whats ur problem?
check dm
Why not do it here ?
@native tide do it here
ok sure
from flask import Flask, render_template, request
app = Flask(__name__)
@app.route('/')
def hello():
username = request.form["username"]
password = request.form["password"]
return render_template("index.html")
if __name__ == '__main__':
app.run("127.0.0.1", port=5000, debug=True, use_reloader=False)```
<!doctype html>
<html>
<head>
<title>Some title</title>
</head>
<body>
<h2>Form</h2>
<div class="login-form">
<form action="/response" method="post">
<div class="form-group">
<input name="username" type="text" class="form-control" placeholder="Username" required="required">
</div>
<div class="form-group">
<input name="password" type="password" class="form-control" placeholder="Password" required="required">
</div>
<div class="form-group">
<button name="submit" type="submit" class="btn btn-primary btn-block">Log in</button>
</div>
</div>
</div>
</body>
</html>```
i need to print the login form data
any idea how to do that?
In your html code you have a <form> element which sends the form to /response when its submitted
action="/response" @app.route('/')
you need to create a coresponding route
basically this:
@app.route('/response')
def form_data():
username = request.form["username"]
password = request.form["password"]
print(username, password)
You can still print data to the console before returning a template render
What's the result of printing request.form ?
Well, no, otherwise you wouldn't get a keyerror
What's the result of printing
request.form?
Just print it to the console for now
gives me error
Which is ?
KeyError: 'username'
Print before trying to access username and password
If you print after an error then yea you'll never get your print
I want you to print request.form before doing anything else in your hello view
oh
from flask import Flask, render_template, request
app = Flask(__name__)
@app.route('/')
def hello():
username = request.form["username"]
password = request.form["password"]
print(username)
print(password)
return render_template("index.html")
if __name__ == '__main__':
app.run("127.0.0.1", port=5000, debug=True, use_reloader=False)```
like this?
still gives me an error though
....
from flask import Flask, render_template, request
app = Flask(__name__)
@app.route('/')
def hello():
print(request.form)
username = request.form["username"]
password = request.form["password"]
return render_template("index.html")
if __name__ == '__main__':
app.run("127.0.0.1", port=5000, debug=True, use_reloader=False)
So it's empty. Did you change the action on your form or is it still pointing to /response ?
i only visited the website, which shows an error but in console it gave that output, together with errors
couldnt access the login form no
That's not my question
Then go back here and read : https://discordapp.com/channels/267624335836053506/366673702533988363/724660476889530459
Hi, can someone help me with django here?
Possibly. Best to just ask the question
Can someone help me correct that code?
@weary bough Looks like it has an accepted answer.
Where can i host a flask app?
anywhere?
Hello folks, I am working on an API using Flask and I am stuck at a problem...
the API uses MVC pattern, the routes are defined in the views and call controller methods to get the data necessary. The problem is that the controller methods return either the queried object from database or None to indicate failure, but the view has no idea of what went wrong so it can't distinguish 404 not found from other errors.
What/how should I improve to be able to distinguish different types of problems the controller can encounter to return a better HTTP code from the view?
I was thinking about returning a tuple containing the object/None and some data but don't know what data would be suitable... returning just the error messages gives the view no hint of what HTTP code it shall return, and returning the HTTP code from controller and just passing it in the view doesn't seem like the right design choice π€
Any input would be appreciated, if you need more context let me know π
@ashen vigil have you tried the @app.errorhandler decorator?
I use a bunch of custom exception classes, and with the @app.errorhandler(MyCustomException) decorator, I setup callback functions which return an error message (along with an appropriate status code) whenever MyCustomException is raised.
that way, my controller classes don't have to handle anything related to status codes, that job is done with the errorhandler decorator (and the callback functions associated with them)
With Django, Iβm trying to use the last bit of the url as an input (e.g. base/Jeff but Iβm not sure how to do it? Iβve managed to make a regex that allows any thing after βbaseβ but not able to find the ending, itβs still localhost and most SO links donβt work for some reason
anyone working with flask and graphql ?
I think that's what you're looking for
It's not quite the relevant part of the docs. But it is an example of what you're looking for
does anyone know how to get the other side of a M2M relationship including the through model?
e.g.:
class LeftSide(models.Model):
left_value = models.IntegerField()
rights = ManyToManyField(LeftSide, through=Through)
class RightSide(models.Model):
right_value = models.IntegerField()
class Through(models.Model):
left = models.ForeignKey(LeftSide, on_delete=models.CASCADE)
right = models.ForeignKey(LeftSide, on_delete=models.CASCADE)
through_value = models.IntegerField()
if I were to access the rights RightSide set of a LeftSide instance, each instance would have the right_value model field, but not the through_value field from the Through model. how do I get both of them together?
Hey guys, I had a quick question about something I'm trying to do in Django...
{% for article in articles %}
<h5 class="articleTitleSection"><a href="/individual_blog/?page=1">{{ article.title }}</a><br> by: {{article.author}}</h5>
{% endfor %}
</ul>```
So basically I have an Article model which contains the title, author, and content. Right now I can view the first article object at `/individual_blog/?page=1`, the 2nd article object at `/individual_blog/?page=2`, and so on etc.
My question is - What do I change in this href attribute (also seen in the first snippet of code) `<a href="/individual_blog/?page=1">` so it doesn't just always go to the 1st page. Instead, if the user were to click on, say, the 2nd link, it brings them to the second page, not just the 1st.
can someone help me
i want to put a picture and paragraph that are in 2 different divs
side by side
how do i do that
use it
install the cdn
thats the best way to do what you're trying to do as far as i know
idk that much python tho
what does this have to do with python?
??
so wrap both images in a div with the class row
and in each div containing the image
assign the div a class of col-lg-6
then it should work
hey
do i need a VPS server to get flask working on a public website (not local)
also can it be done on a raspberry pi and connect it with domainname?
@worn crane you can use page={{ forloop.counter }}
anyone who knows selenium
how to make a paragraph element responsive (meaning, if i enter 5000 words than it should increase in size to accomodate this may words)
@midnight kernel I have gone through many MVC API projects using flask on GitHub and came to this conclusion too. Majority of them doesn't even use controller with views, or uses views for static .html files. Would you mind sharing your project for reference if it is public?
Also thanks for the reply.
are there any good python frameworks available for making webinterfaces for python scripts?
i suppose the builtin http.server module is good enough for serving, it's more the content generation i'm interested in.
what are my options for a webapp that is communicating with a script on the server in real time?
self.driver.execute_script('''
var fDialog = document.querySelector('div[role="dialog"] .isgrP');
fDialog.scrollTop = fDialog.scrollHeight
''')
what is this i encountered this while learning selenium
noone here replies
It executes javascript @rapid epoch
@bleak bobcat can you explain what is in there
Gets an element div with a class isgrP and an attribute role (value dialog) and scroll the page to it ? Maybe
@silver plank Flask would probably be the best in your case
Hello,
I'm trying to use beautiful soup to do this:
I want to take a large div out of a website and then for every p,h1,h2,h3 element inside the div I want to extract the .string from that element, any idea how I go about that?
This is what I have so far:
def get_full_story(req_content):
identifier = "story-body"
soup = BeautifulSoup(req_content,features="lxml")
found = soup.find("div",identifier)
for elem in found:```
which is the best and easy way to deploy Django app to VPS ???
Use elastic beanstalk @snow sierra
people who make websites here, do you guys use templates or do u make ur own stuff with html/css?
such as navbars and common things in a website
navbar/footer
or do u make ur own stuff and save it and reuse it?
Depends
Mostly use a framework and heavily customize everything
I use React for frontend along with material UI @distant trout
ohh i still havevnt got to that
is react relatively easy to learn?
i kinda know basics of js, idk if i should learn react yet
No
oh yikes
React is a hard library
You need to make sure you own javascript
especially classes and objects
hmm
yeah i got a long way to go Xd
is there an easy alternative?
or should i stick to css
using flexbox/css grids
and frameworks like bootstrap
styling frameworks?
could u name some, not familiar with that term
like bootstrap and tailwind?
Use elastic beanstalk @snow sierra
@rustic pebble thanks ,
Where can i find list of modules that i can use in flask like fpaks login and flask socketio
???
but it is not easy.. i am doing any kind server jobs, but i need for students ..
I am creating a website that has mini services created using Flask. So far I have URL Shortner, MP4 Video to MP3 Audio, To Do List.
Anyone have any other ideas as to what I could add?
Crud app?
yeah
Or something with scraping
Or web streaming service like netflix
It would be interesting
I saw somewhere post abt it like you need to find a way to protect videos from downloading from your site
How to add likes
And similar things
Pagination
Hey guys, I'm trying to learn Django and am having this weird issue where python manage.py startapp <myAppName> seems to execute twice. Here's what I've done:
- Created a virtual environment using
python -m venv myVenv - Began using this venv by using
source myVenv/bin/acivate - Installed django using
pip install django - Created a Django project using
django-admin startproject myProjectName - Attempted to create an app using
python manage.py startapp <myAppName>
I believe step 5 is executing twice because this is the result inside <myProjectName>. I also double checked that Django is only installed once using pip list
Also, which python confirms I am using the Python from my virtual environment
yeah thats my question haha
you might need to delete it all and do it again
i tried
That is funky.
Not exactly a solution, but I would check out dockers. Started using them myself recently. Amazing. Makes life so much easier. Small curve, but totally worth it.
If it's relevant, I'm using Django 3.0.7 on MacOS 10.15.5
ill look into dockers
oh docker is a venv thing
i dont think its an issue with my venv becuase creating the project itself yielded no issues
jk its def a venv thign
django-admin yields two of every command available
You wouldn't have the venv open twice or something right?
I don't believe so
when i deactivate once it returns to my default python environment
hmmm strange
i called pip uninstall django
and it worked
and django is no longer working
but it still appears in pip list
i think im going to generate a new venv
Try using pipenv
pip install pipenv
pipenv install django
Once it's done, activate the environment using "pipenv shell"
creating a new venv did the trick
super weird
django was double installed or something
ty for your help though β€οΈ
πΊ
Some tips that helped me out a lot during the Django basics: When following your tutorial/book, use VERY descriptive model names/view names. "model_MODELNAME*, "view_VIEWNAME".
Hardest part of Django (or any framework) at first is learning to separate what's python code and what's Django framework.
Everything is gonna feel mixed and it's hard to tell where things are coming from
gotcha good to know ty
one quick q as well: I'm following corey schafer's 2.1 tutorial and read there arent a ton of breaking changes in 3.0. Is this true? Or should I just look for a 3.0 tutorial
I just like Corey Schafer's teaching style : P
The core Django foundations are solid. They haven't changed.
perfect ty
How do I find the model class from a DoesNotExist exception instance?
Context if needed: #help-falafel message
hey guys
i got problems deploying my flask app
[Tue Jun 23 16:22:58.386914 2020] [wsgi:error] [pid 3033:tid 2970608672] [client 192.168.1.18:48168] File "/var/www/webApp/webapp.wsgi", line 7, in <module>
[Tue Jun 23 16:22:58.387042 2020] [wsgi:error] [pid 3033:tid 2970608672] [client 192.168.1.18:48168] from webApp import app as application
[Tue Jun 23 16:22:58.387132 2020] [wsgi:error] [pid 3033:tid 2970608672] [client 192.168.1.18:48168] ImportError: cannot import name app
[Tue Jun 23 16:22:58.537612 2020] [wsgi:error] [pid 3033:tid 2945430560] [client 192.168.1.18:48170] mod_wsgi (pid=3033): Failed to exec Python script file '/var/www/webApp/webapp.wsgi'.
[Tue Jun 23 16:22:58.537750 2020] [wsgi:error] [pid 3033:tid 2945430560] [client 192.168.1.18:48170] mod_wsgi (pid=3033): Exception occurred processing WSGI script '/var/www/webApp/webapp.wsgi'.
[Tue Jun 23 16:22:58.537837 2020] [wsgi:error] [pid 3033:tid 2945430560] [client 192.168.1.18:48170] Traceback (most recent call last):
[Tue Jun 23 16:22:58.537927 2020] [wsgi:error] [pid 3033:tid 2945430560] [client 192.168.1.18:48170] File "/var/www/webApp/webapp.wsgi", line 7, in <module>
[Tue Jun 23 16:22:58.538050 2020] [wsgi:error] [pid 3033:tid 2945430560] [client 192.168.1.18:48170] from webApp import app as application
[Tue Jun 23 16:22:58.538140 2020] [wsgi:error] [pid 3033:tid 2945430560] [client 192.168.1.18:48170] ImportError: cannot import name app
this is the error i get
@native tide thats aws?
raspberry pi, i got another error now, i almost fixed it i think
mod-wsgi or apache runs my python3 script as python2
and i get invalid syntax error
[Tue Jun 23 17:01:07.116207 2020] [wsgi:error] [pid 8519:tid 3048207392] [client 192.168.1.18:49064] mod_wsgi (pid=8519): Failed to exec Python script file '/var/www/webApp/webapp.wsgi'.
[Tue Jun 23 17:01:07.116317 2020] [wsgi:error] [pid 8519:tid 3048207392] [client 192.168.1.18:49064] mod_wsgi (pid=8519): Exception occurred processing WSGI script '/var/www/webApp/webapp.wsgi'.
[Tue Jun 23 17:01:07.116381 2020] [wsgi:error] [pid 8519:tid 3048207392] [client 192.168.1.18:49064] Traceback (most recent call last):
[Tue Jun 23 17:01:07.116443 2020] [wsgi:error] [pid 8519:tid 3048207392] [client 192.168.1.18:49064] File "/var/www/webApp/webapp.wsgi", line 7, in <module>
[Tue Jun 23 17:01:07.116608 2020] [wsgi:error] [pid 8519:tid 3048207392] [client 192.168.1.18:49064] from webApp import app as application
[Tue Jun 23 17:01:07.116748 2020] [wsgi:error] [pid 8519:tid 3048207392] [client 192.168.1.18:49064] File "/var/www/webApp/webApp/__init__.py", line 22
[Tue Jun 23 17:01:07.116777 2020] [wsgi:error] [pid 8519:tid 3048207392] [client 192.168.1.18:49064] username.send_keys(f"{username1}")
[Tue Jun 23 17:01:07.116802 2020] [wsgi:error] [pid 8519:tid 3048207392] [client 192.168.1.18:49064] ^
[Tue Jun 23 17:01:07.116825 2020] [wsgi:error] [pid 8519:tid 3048207392] [client 192.168.1.18:49064] SyntaxError: invalid syntax
got it working
Solved my problem:
class Model(models.Model):
class Meta:
abstract = True
def __init_subclass__(cls):
if not cls._meta.abstract:
cls.DoesNotExist.model = cls
cls.MultipleObjectsReturned.model = cls
huys how to prevent user from downloading images and videos on site in flask??
Hi guys, is there a tool where u guys use in order to build web design? For example like there is Elementor for wordpress, so looking for something that is standalone that can generate code (lets say for bootstrap or anything u think)
Dont know if this goes into this category, but how do i get rid of everything except the 21 in this line? : <span class="temperature temperature--warm" role="text">21<span aria-label="grader celsius" class="temperature__degree" title="grader celsius">Β°</span></span>
@rigid mist Sounds like a parsing job. If you're making a python script, you can use bs4 (BeautifulSoup 4)
I am, but i dont know how to "aim in" on the 21, it being text, but not a por h1, h2, h3 or h4.
huys how to prevent user from downloading images and videos on site in flask??
@fickle fox
Impossible
By viewing it in the browser, they downloaded it
I dont think its possible to protect, most of the difficult sites to get the video from use chunks, but its still possible to download it
chunks?
as in, send 4-5 seconds in every GET request
so its sends the video split into many chunks instead of in 1 file
however its always possible to mix those and create it into 1 file
oh so thing i saw was lie
if there is way to protect it i d like to use it for sure
but tq
There are multiple video security providers which makes it hard to do so
not sure waht they are using exactly, but there are way to make it difficult to do so
however, never impossible
@rigid mist https://stackoverflow.com/questions/38133759/how-to-get-text-from-span-tag-in-beautifulsoup
@fickle fox I dont rly thinking netflix uses the request to increase the security of their services but to, rather, increase the performance, by downloading the video in chunks the buffer time is minimal
can someone tell me if i always have to start off making my website responsive?
can i just add in media query when every thing looks fine on a desktop 1920x1080 monitor?
Yes you can add a media query but you will need to adjust the mobile version of your website accordingly
it wont magically fit into place
ahh
do people usually make responsive website from the start?
or do it at the end of a project
It depends, I usually layout the design at my best capability, making it responsive filling it with demo data - placeholders, then I proceed into building the backend which will then fill the place of the placeholders
That is my opinion and method, doesn't mean you have to follow it
If you got a solid plan in your head you can jump in the backend, build everything and then just leave the design for last
I like to see the frontend rollout as I build the backend, so having an already existing frontend base feelsgood
I use the MVC model, model - view - controller
Basically, view makes a request, a controller takes that request, processes it and updates the model, then the view is updated and user sees the result
whatever that is π i need to learn a lot
Anyone have a good resource to get a good understanding of using React w/ django?
Is it possible to figure out (with python) which ajax requests are made when i send a http get to an URL?
@young gull wdym?
You can't utilize the entire tools of django with react, react is a frontend SPA framework. you can use it with django rest framework
@native tide
any good resource for it?
Check this: https://medium.com/@gazzaazhari/django-backend-react-frontend-basic-tutorial-6249af7964e4
Medium usually posts very good and consice articles
@native tide ive used react with flask. its possible to serve the index.html page that comes with the react build using flask, but its... tricky, and almost always better to just serve that index.html with nginx
@rustic pebble When i browse to an url in chrome i can see multiple xhr requests in the dev tools.
Yes
np
Yup
You can use react with anything you just need restapi
not anything else
@young gull
hey guys, i want to start making web applications and I've heard you can use herokuapp to make web applications. Should i use that or just use flask?
U can use flask to make webapps and then gunicorn to host them on heroku
anyone have a good tutorial or know how I can make a web app hosted through amazon s3?
or should i be looking elsewhere for the host
Guys I tried to automate my whatsapp with selenium but it didn't work.so I imported a code from online still it didn't work can you help me
!rule 5 @native tide
5. Do not provide or request help on projects that may break laws, breach terms of services, be considered malicious/inappropriate or be for graded coursework/exams.
@native tide
you must not directly or through automated means: (a) reverse engineer, alter, modify, create derivative works from, decompile, or extract code from our Services; (b) send, store, or transmit viruses or other harmful computer code through or onto our Services; (c) gain or attempt to gain unauthorized access to our Services or systems; (d) interfere with or disrupt the integrity or performance of our Services;
https://www.whatsapp.com/legal?doc=terms-of-service&version=20200128
@snow dragonthanks. I didn't really knew tat
import random
app = Flask(__name__)
@app.route("/")
def index():
num = random.randint(0, 1)
return render_template("index.html", num = num)
@app.route("/bye")
def bye():
return "<h2>Good Bye</h2>"
if __name__ == "__main__":
app.run()
return render_template("index.html", num = num)
^
TabError: inconsistent use of tabs and spaces in indentation
@silent knoll you have both spaces and tabs mixed
anyone have a good tutorial or know how I can make a web app hosted through amazon s3?
@hallow jacinth you cant host the web app on S3. S3 is their storage service however you can use Ec2 but i dont recommend it because it is expensive... Use Heroku for now!
Hi, I'm making a simple server with flask and while I'm copy-pasting tutorialimplementing login I found that the session doesn't get saved. What am I doing wrong?
@app.route('/login', methods=['POST'])
def login():
print("Last session")
print(session)
req = request.values
if 'id' in session.keys():
return {"message": "Already logged in"}, 200
else:
res = helper.login(req['id'], req['password'])
if res:
session['id'] = req['id']
session.modified = True
print("After changing")
print(session)
return {"message": "Logged in"}, 200
return {"message": "Invalid credential"}, 401
output :
Last session
<SecureCookieSession {}>
After changing
<SecureCookieSession {'id': 'test'}>
127.0.0.1 - - [24/Jun/2020 13:58:46] "POST /login HTTP/1.1" 200 -
127.0.0.1 - - [24/Jun/2020 13:58:52] "POST /login HTTP/1.1" 200 -
Last session
<SecureCookieSession {}>
After changing
<SecureCookieSession {'id': 'test'}>
setting secure_key btw
app = Flask(__name__)
app.secret_key = ':/'
any idea?
take a look at that and change the secret key
What do you guys use to compress images for web (decrease their buffer). Is Pillow good enough or?
@native tide
I'd recommend you use flask-login
Flask-Login provides user session management for Flask. It handles the common tasks of logging in, logging out, and remembering your usersβ sessions over extended periods of time.
@native tide it was to hide my key xD
ill check out that, thanks
import os
SECRET_KEY = os.environ.get('SECRET_KEY')
use that to hide the important data
a.k.a environment variables
thats a good idea
why session doesnt work for me tho
what's the issue ?
how can i scroll down the following/follwers list in instagram using selenium?
Oof
what?
no python selenium
yeah just like me
i'm looking for it
already saw these stuffs nothing works
huh?
ANYONE SOLVE MY PROBLEM
The channel doesn't really belong to you
@rapid epoch if you wanted a dedicated help you should've asked in help channel
Learn how to communicate
noone is ready to help
you're not allowed to crawl/automate smth in instagram IIRC
except the api they provide
ok lol
You can't attempt to create accounts or access or collect information in unauthorized ways. This includes creating accounts or collecting information in an automated way without our express permission.
@native tide i would ask some fundemental questions ex) design patterns
i'm not specialized in web dev but at least that's what i heard of from my friends
Thanks :)
Hi, simple question. Do you know if there is a parameter that can be placed in a field to prevent the Chrome proposal list?
Try putting autocomplete="off" attribute in the input
@wispy tinsel Thx you, it's working π
No problem ππ»
Morning!
So i', getting this error from my model.
ValidationError(
django.core.exceptions.ValidationError: ['ββ value has an invalid format. It must be in YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ] format.']
can you send me the snippet ?
Here's what i got on models.py
class Promo(models.Model):
user = models.CharField(max_length=50)
passwd = models.CharField(max_length=50)
pub_date = models.DateTimeField(auto_now=True, null=True, blank=True)
image = models.ImageField(upload_to='images/')
nif = models.CharField(max_length=9)
promo_redeem = models.CharField(max_length=20, null=True, blank=True)
ok then can you tell me the line where exactly this error is
ValidationError(
django.core.exceptions.ValidationError: ['ββ value has an invalid format. It must be in YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ] format.'] this error appears when you fill the form or when the model is just excuted??
When i try running manage.py migrate
ok
pub_date = models.DateTimeField(auto_now=True, null=True, blank=True) this is where is comes right>>
??*
When i did the first makemigrations thats the line the error popped but now it does not specify which line throws the error.
can you remove blank=True and then give it a try?? from pub_date
and make migration again
Let me check.
if your pub_date is auto_now then why u need it null?
database can auto fill this field when u submit the data
I had it like that checking some stuff from stackoverflow.
Did the change but same error.
pub_date = models.DateTimeField(auto_now=True)
and try add default=None
like this
Before adding the DateTimeField it was smooth then added a couple more fields. That's when the error popped out, then django started whinning about setting defaults to each field.
models.DateTimeField(auto_now=True, default=None
like this
@rancid crane )
models.DateTimeField(auto_now=True, default=None) try this
then make migration
K.
ERRORS:
promo.Promo.pub_date: (fields.E160) The options auto_now, auto_now_add, and default are mutually exclusive. Only one of these options may be present.```
k.
haha now this is interesting
I do live in the caribbean, wouldnt it has something to do with timezone format django expects?
It threw the same error.
ok then tell me what database you are connecting with??
Postgres.
mmm
these code i send you worked very well in mysql
idk if it is a timezone related issuue\
never happened to me
can u send me the full errors
?
Yeah.
models.DateTimeField(auto_now=True) you can try this also
let me know it this worked
if it works*
Threw me this: ```(django3.0.7-3.8) E:\Dev\fritolaypromo\LandingPage>python manage.py makemigrations
You are trying to change the nullable field 'pub_date' on promo to non-nullable without a default; we can't do that (the database needs something to populate existing rows).
Please select a fix:
- Provide a one-off default now (will be set on all existing rows with a null value for this column)
- Ignore for now, and let me handle existing rows with NULL myself (e.g. because you added a RunPython or RunSQL operation to handle NULL values in a previous data migration)
- Quit, and let me add a default in models.py```
models.DateTimeField(auto_now=True) you can try this also
@rancid crane if this didnt worked then in case
models.DateTimeField(auto_now=True, default=True) should worked π¦
Hope all these previous migrations i have done are not getting in the way. Should i rollback to when it worked fine then apply your suggestions?
if you dont have any existing records and this is your testing server then you can
just delete a migrations EXCEPT init.py ie in the folder migrations
all migrations*
then
u need to delete the table in the postgres
tables
all tables in the postgress
@dreamy pecan can you share you screen
this can be more helpfull
this might be helpfull
ok π GL
Thanks for the assistance thou. @rancid crane
Thank you @native tide
hello how can i use css on pycharm
i have added django and css in project interpreter but it seems django is not recoginsing css
use style tag
in html
and put your css code there
don't use inline css
u could better just link them
Anyone experienced with Django, and maybe even DRF ? I have developed a REST API and would appreciate some feedback to see if I'm not going in the wrong direction before carrying on. Not my first website, but is my first Django project (Java/Spring guy here). Project is still very small: 993 LOC.
Hi guys,
I have a model, called "Blog", which has a date property. I need to order my blogs by date, descending. Why is this so difficult? At the moment I do the following:
Blog.objects.order_by('date').reverse()
How do you use the asc() and desc(). I do not understand the Django documentation regarding this.
@raw drum You can use Blog.objects.order_by('-date').
@dry pawn Damn. Thanks for that. Now that I read the documentation again, slowly, I see the "-" is used for desc:
You're welcome.
i am trying get image ..
{% for i in profile.all %}
<p>{{i.name}}</p>
<p><img src={{i.photo}}></p>
{% endfor %}
{{i.photo}} getting photo url.. but when using img src does not show .. any idea?? (i want without static)
@snow sierra If you browse the url directly, does it work ?
also not, but url is correct
How ?
ok wait.. i'll screen
src is meant to tell the browser where to find the picture. If browser cannot open url specified by src, it cannot work.
Yeah, so src is not correct, that's my point.
I don't deny the picture is where you think it is
Is uploads folder being served by your webserver ?
Is uploads folder being served by your webserver ?
@bleak bobcat what i do for it?
did you mean MEDIA_ROOT in settings?
port 8000 is your Django application I guess. So you either need it to serve the pictures, or you need another server to serve the pictures. Or you must encode your pictures in base64 (https://stackoverflow.com/questions/8499633/how-to-display-base64-images-in-html).
Yea but not only
ok ok ... i was trying without static .. i'll do with that django docs ..
i through if HTML gives me path of image then <img src ... > must work :d
The idea is that browser will fetch html, analyze html, see the src attribute and then fetch picture using provided url. So provided url must serve picture.
thank you mates π
look at this
{% load static %}
<img src="{% static "my_app/example.jpg" %}" alt="My image">
but here i want dynamic image as said above ... {{i.photo}} because every student have own pic ..
Then it's media, not static. You need to add uploads dir to the media files django should serve
Then it's media, not static. You need to add uploads dir to the media files django should serve
@bleak bobcat right! can you give me good link about it? π
around ImageField docs i did not get enough recourses for my brain :X
I want to save images in the static directory (situated in the root directory of my application).
What works for me is creating an image path like this
image_path = os.path.join(current_app.root_path, current_app.config['IMAGE_DIR'], safe_filename)
However, if I try to use url_for for relative paths and say
image_path = os.path.join(url_for('static', filename='assets/images'), safe_filename)
it doesn't work anymore. Anyone knows why?
PS: Working with Flask
Fussing with Django REST. Is there a good method for serialization for extra actions? Because I can specify this:
@action(detail=False, serializer_class=MySerializer, methods=['post'])
def my_extra_action(self, request):
But it'd still need to be consumed by MySerializer and checked with is_valid
Mostly doing that so it'll self document because I'm lazy
@app.route('/profile')
def me():
discord = make_session(token=session.get('oauth2_token'))
user = discord.get(API_BASE_URL + '/users/@me').json()
guilds = discord.get(API_BASE_URL + '/users/@me/guilds').json()
connections = discord.get(API_BASE_URL + '/users/@me/connections').json()
return render_template("index.html", content=user["username"])
error:
jinja2.exceptions.TemplateSyntaxError: expected token 'end of print statement', got 'string'
show us the template
@native tide
Forgive my naivety, but I'm trying to follow Corey Schafer's "Learning Django" series and am having an issue when calling python manage.py makemigrations. I get the following error:
CommandError: Conflicting migrations detected; multiple leaf nodes in the migration graph: (0001_initial 3, 0003_logentry_add_action_flag_choices in admin; 0001_initial 3, 0011_update_proxy_permissions in auth; 0001_initial, 0001_initial 3 in sessions; 0001_initial 3, 0002_remove_content_type_name in contenttypes).
To fix them run 'python manage.py makemigrations --merge'
It says to call python manage.py makemigrations --merge, so I do. Doing that yields another error:
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/Users/Justin/Documents/learningDjango/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/Users/Justin/Documents/learningDjango/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/Justin/Documents/learningDjango/venv/lib/python3.7/site-packages/django/core/management/base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/Justin/Documents/learningDjango/venv/lib/python3.7/site-packages/django/core/management/base.py", line 369, in execute
output = self.handle(*args, **options)
File "/Users/Justin/Documents/learningDjango/venv/lib/python3.7/site-packages/django/core/management/base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "/Users/Justin/Documents/learningDjango/venv/lib/python3.7/site-packages/django/core/management/commands/makemigrations.py", line 133, in handle
return self.handle_merge(loader, conflicts)
File "/Users/Justin/Documents/learningDjango/venv/lib/python3.7/site-packages/django/core/management/commands/makemigrations.py", line 260, in handle_merge
raise ValueError("Could not find common ancestor of %s" % migration_names)
ValueError: Could not find common ancestor of {'0001_initial 3', '0002_remove_content_type_name'}
Is anyone familiar with this kind of error? I know that it has something to do with the management of databases in my project. However, I haven't even touched any of that yet; I've only had it serve some static html pages at different endpoints.
{% extends "base.html" %}
{% block css %}
{{ url_for('static', filename='style.css') }}
{% endblock %}
{% block title %}Home{% endblock %}
{% block content%}
<p>Hello, {{ content }}!</p>
{% endblock %}
@native tide
Is this the only .html file you have?
no
I see no errors in here, give me the traceback of the error.
one moment
return _render(
File "/home/luke/.local/lib/python3.8/site-packages/flask/templating.py", line 120, in _render
rv = template.render(context)
File "/home/luke/.local/lib/python3.8/site-packages/jinja2/environment.py", line 1090, in render
self.environment.handle_exception()
File "/home/luke/.local/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
reraise(*rewrite_traceback_stack(source=source))
File "/home/luke/.local/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
raise value.with_traceback(tb)
File "/media/luke/TOSHIBA EXT/Developing/Flask/User/templates/index.html", line 1, in top-level template code
{% extends "base.html" %}
File "/home/luke/.local/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
reraise(*rewrite_traceback_stack(source=source))
File "/home/luke/.local/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
raise value.with_traceback(tb)
File "/media/luke/TOSHIBA EXT/Developing/Flask/User/templates/base.html", line 23, in template
<li><a href="{{url_for("index")"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
jinja2.exceptions.TemplateSyntaxError: expected token 'end of print statement', got 'string'
oh wow
i think i might see it
{{url_for("index")
i didnt know a traceback logged π€¦ββοΈ
π
so it should be
{{ url_for('index') }}
{{url_for('index')}}
yep
thats what im trying
wow dude
thanks
π
amazing
np
have an amazing day
Hello guys, I want to get a job as a web developer later in my life but I want to learn it from basics first. Can someone please help me with free courses and the correct sequence of learning. By the way, I know the basics of HTML, CSS, jinja 2, python, flask and SQL.
Please tag me as well so that I get a ping
how can I embed a variable in url_for
src="{{ url_for('static', filename='assets/images/projects/image_path') }}"
image_path is my variable
and the line above doesn't work
nvm found out ```
src="{{url_for('static', filename='assets/images/projects/')}}{{image_path}}"
Hi guys, I'm trying to get started with Python and my main goal is to make little **online ** projects for practice and obviously if I'm going to get better, I'll do more complicated things. However as a complete beginner I'm not really sure if Python is a correct language for this matter. My friend who is working at my company's IT department said that for Python you usually need to use Linux for things to work 100%. But I don't really want to use Linux, is that really a thing?
Also if it's not the case, could anyone give me a roadmap or some kind of guide on what are the most important things to understand and what beginner projects usually people make to practice?
Well sorry for the wall of text, but I got addressed here from an another forum to chat :d
Python can be installed on Windows and so works on it, I don't know what your friend really meant.
For online projects, do you mean websites? Desktop apps? Mobile apps? Scripts?
These all can be done with python and since it's a scripting language, it can be used for building websites as well, I have had some experience with it but it's not solid yet and I haven't work on my own projects.
Python is not a scripting language.
You don't need to run it in linux to make 'things work 100%'
For your use, it'll be allright to use any os, it is true that there might be a few OS dependant libraries but you will most likely not be affected by this.
Not a scripting language?
@wind escarp I don't know what my friend meant either, he said usually python developers using Linux. And yes as for my goals I mean websites and different things on websites, like little programs or things like that. It's important for me to be globally accessable not only at my PC or after installation
General purpose laguage
General purpose laguage
Right, but still a scripting language.
Maybe in 1991
but no today
doesn't matter how you try to look at it
it is not
Python works fine on either os. It really doesn't have that many differences, certainly not for more users.
Most*
@wind escarp I don't know what my friend meant either, he said usually python developers using Linux. And yes as for my goals I mean websites and different things on websites, like little programs or things like that. It's important for me to be globally accessable not only at my PC or after installation
@vague bison
Yeah gotcha, head for python docs, then "automating the boring stuff with python" (book)
doesn't matter how you try to look at it
O.K.
?
@rancid crane Solved my issue this morning, had something to do with the pycache storing dump data from previous postgres models. Once i removed them your suggestion worked.
idk for me rn if sat me down in front of a computer and told me to make a web app i would not be able to do it without a video guide
There are plenty "video guides" online, free and premium. Depends what you're looking for.
hello how can i use css code inside django
lol im doing the corey shafer flask guide
yeah, that's perfect as a starting guide
hm can someone help me please
@opal robin wait for someone to help you, don't spam pls
look at that
actually i'm doing it another way
i'm followng a tutorials
this is my settings .py file
STATIC_ROOT= ''
STATICFILES_DIRS = (
os.path.join(BASE_DIR,'assets'),
)```
hello, i am working with the discord oauth. i was wondering how do i check if the user that verified with there oauth has manage_server permission? (btw im using flask)
background:blue;
}
this is my css
<html>
<head>
<link rel="stylesheet" href="/static/styles.css">
<title>Articles</title>
</head>
<body>
<div class="wrapper">
{%block content%}
{%endblock%}
</div>
</body>
</html>```
and this is my html
what is your issue
i seems like the django has recognised a background color but i can;t make any changes to it
i can't use css
on django
background-color: blue;
i don't think that's the problem
send us a tree of your app
restart your app
and see if the changes apply t hen
how can i do that
try restarting your app everytime you change the color
don't see any static folder tho'
you don't need one in django iirc
what
don't see any static folder tho'
@native tide i have one called assets
should i make assets inside of static?
yes
STATIC_ROOT= '' STATICFILES_DIRS = ( os.path.join(BASE_DIR,'assets'), )```
@opal robin what's then with that file path pointing to static
bruh
i just followed a tutorials
learn more python before trying to learn django
or python in general
{% load static%}
<html>
<head>
<link rel="stylesheet" href="assets/styles.css">
<title>Articles</title>
</head>
<body>
<div class="wrapper">
{%block content%}
{%endblock%}
</div>
</body>
</html>
can you please just say what i'm doing wrong
try this
ok
hello, i am working with the discord oauth. i was wondering how do i check if the user that verified with there oauth has manage_server permission? (btw im using flask)
it removed the green background which i was having before and now it's only white
but i get no error
white is the default π€¦ββοΈ
learn html and css before attempting to learn django aswell
i know that
i'm just saying that django isn't showing an error
but i's not changing color as i wish
{% load static%}
<html>
<head>
<link rel="stylesheet" href="/assets/styles.css">
<title>Articles</title>
</head>
<body>
<div class="wrapper">
{%block content%}
{%endblock%}
</div>
</body>
</html>
try this
did you save the file
idk bout that
@native tide
@opal robin I m not sure then, but review the tutorial you might have missed sth
you don't have a static directory, but still you are mentioning it in the html file
btw learn html, css, and python before going further, its just extremely dumb not to
you can add a js script reloading it when submitted
you don't have a static directory, but still you are mentioning it in the html file
@native tide i aslo tried creating a directory named static
okay byeee
and than placing assets isntead of it
anyway thank you
okay byeee
@native tide why do you have to be so rude
@barren salmon you need to use redirect instead of rendering the template again
@opal robin dude your literally coming here with absolutely no knowledge
lol all good
yeah everybody can seem to be another person on online forums
I know it shows that, but use redirect(url_for('[the view function]')) @barren salmon
that's how it works
this days and since the forums were inveted
it's hard to be nice
lol
:/
when forums weren't invented, people actually learned the language lmao
anyway goodbye
Laravel or Django?? which is strong in web what you think guys ..
laravel is more common
php is still more common
if you ran into any issues you would most likely have better luck finding them if you were using php
and it is easier to host on a web server
sure !... why i asked it :dd i don't know, just was typing something :dd
i think we can compare Laravel to Wagtail and not to django.. π
guys idk if making a webapp is the most efficient way to do this
but
all i want to do is have an interactive GIS on a website that maps out real time data
how should i approach this project?
what is class based view?
can someone help me
when ever i shrink my screen the footer breaks
how do i fix that
in css
is it better to use explicit or implicit css grids?
rows/columns numbers VS naming them in grid-template-areas
Anyone know other ways beyond HTTP interfaces to integrate a django app with other softwares?
I really don't know if this is considered Advertising,
But is there a web dev / web designer here I am looking to commission one for a project
hello
Does anyone know what is the Purpose of Using DurationField in django
@distant trout this is not a CSS group but it depends on what you actually do. Naming columns might be really useful if you have a repetitive design on multiple pages.
example
grid-template-columns: [sidebar-start] 8rem [sidebar-end full-start] minmax(6rem, 1fr) [center-start] repeat(8, [col-start] minmax(min-content, 14rem) [col-end]) [center-end] minmax(6rem, 1fr) [full-end];
here you know that the first column from sidebar-start to sidebar-end you have the navigation bar; then full-start to full-end you have an entire section spanning from the navigation bar to the end of the document width
You can get more organised if you know what you're doing.
Trying to get a Flask app to work. It runs with flask's dev server but not in apache
~/ansura/ansura-website/ansurasite.wsgi
import sys
sys.path.insert(0, "/home/crazygmr101/ansura/ansura-site")
from main import app as application
~/ansura/ansura-website
βββ ansurasite.wsgi
βββ main.py
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName ansura.xyz
ServerAlias www.ansura.xyz
WSGIDaemonProcess ansurasite user=crazygmr101 group=crazygmr101 threads=5
WSGIScriptAlias / /home/crazygmr101/ansura/ansura-website/ansurasite.wsgi
<Directory /home/crazygmr101/ansura/ansura-website>
WSGIProcessGroup yourapplication
WSGIApplicationGroup %{GLOBAL}
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =ansura.xyz [OR]
RewriteCond %{SERVER_NAME} =www.ansura.xyz
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
/etc/apache2/sites-available/ansura.conf
no matter what page i access, I get a 404 (apache's default 404, not my flask app's)
if anyone needs to see other files, lmk
"If you access the server via IP address, Apache will return based on its default site configuration in /etc/sites-available/000-default.conf. So if you want to access your WSGI server via IP address, you should disable the Apache default site configuration first:"
sudo a2dissite 000-default.conf
service apache2 restart```
what if im trying to use the url tho?
and i will do that
elaborate pls
"If you access the server via IP address, A
nothing is enabled except for ansura.conf and ansura-le-ssl.conf, it's SSL counterpart
WSGIScriptAlias / /home/crazygmr101/ansura/ansura-website/ansurasite.wsgi
why do you have 2 /
in the alias
im assuming / (site root) is being mapped to "/home/crazygmr101/ansura/ansura-website/ansurasite.wsgi" (location)
i just followed flask's documentation on the matter
WSGIDaemonProcess ansurasite user=crazygmr101 group=crazygmr101 threads=5
seems like it should create a process called ansurasite under my user and group, and htop shows no such process
yeah, that's quite odd. I ll come back if I have other ideas. If you find out tho' let me know as well, I m curious
alr
ty
maybe try and put __init__.py
in your ansura dir
and do what with it?
idk maybe is not read by python as a dir
if you don't have that
look at this
alr
still nothing
import main
app = main.app
ansurasite.wsgi
import sys
import importlib
sys.path.insert(0, "/home/crazygmr101/ansura/ansura-site")
#from main import app as application
app = importlib.import_module("ansura-website").main.app
i tried each of the last 2 lines
same error?
yup
do you have a route in your main file
?
Assuming the main.py script you posted is not redacted, you're potentially missing the actual route.
put
@app.route('/')
def hello_world():
return 'hello world!'
in your main
as said above, this site works on flask's dev server
so i have everything set up on the flask side of things
mhm, mkay. Anyway, let me know if you figure it out
if ):
post on stackoverflow, maybe the boys will help
I ll help you with an upvote
:))
i mean i could just run waitress
and sudo start it
so it can bind to port 80
xD
What do you mean by "error" ?
my background image is not appearing
the path is wrong
That's an html related question, but whatever. The best you can do is get an IDE and structure you files as follows
.
βββ images
βΒ Β βββ library.jpg
βββ index.html
then you can point to your image like this src('/images/library.jpg')
the heck
it also broke my term encoding :S
the heck did you do :))
idek
so like, im just trying to see if i can get my flask app running standalone firstt
except, ya know, HTTPS
can i just like.. run it like this and pretend wsgi doesnt exist 
have you tried testing wsgi standalone
as in gunicorn or something like uwsgi?
basically, uwsgi --http 127.0.0.1:5000 --module myproject:app that
yea
does that work?
"could not load config" or someth
sec
thats with -http and -https-socket
also --module isnt a thing apparently
-.-
try just main not main:app
Package: uwsgi
Version: 2.0.15-10.2ubuntu2.1
Priority: optional
Section: universe/web
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: uWSGI packaging team <pkg-uwsgi-devel@lists.alioth.debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 109 kB
Depends: uwsgi-core (= 2.0.15-10.2ubuntu2.1)
Homepage: http://projects.unbit.it/uwsgi/
Download-Size: 16.9 kB
APT-Manual-Installed: yes
APT-Sources: http://us.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages
Description: fast, self-healing application container server
uWSGI presents a complete stack for networked/clustered web applications,
implementing message/object passing, caching, RPC and process management.
It uses the uwsgi protocol for all the networking/interprocess communications.
.
uWSGI can be run in preforking, threaded, asynchronous/evented modes and
supports various forms of green threads/coroutines (such as uGreen, Greenlet,
Fiber). uWSGI provides several methods of configuration: via command line,
via environment variables, via XML, INI, YAML configuration files, via LDAP
and more.
.
On top of all this, it is designed to be fully modular. This means that
different plugins can be used in order to add compatibility with tons of
different technology on top of the same core.
.
This package depends on uWSGI core binary and installs:
* init.d script for running uWSGI daemon(s) with options defined in custom
user-created configuration files
* infrastructure for running daemons (like common locations of communication
sockets, logs)
N: There is 1 additional record. Please use the '-a' switch to see it
not sure if the version matters
and oki
=/
shouldn't matter that much
Ah, I see
you forgot to add --wsgi-file to the parameters
Well
I want to say just running uwsgi alone will give valid params, which I'd want to see now
but I cant get my copy to run because someone doesn't support virtual environments correctly
well i did discover a thing
there's an apt version
and a pip version
could that be why?
Maybe but I find that unlikely
I want to say just running
uwsgialone will give valid params, which I'd want to see now
i yeeted the apt version before you said that
also
both pip and sourcec
whine about this
is there a python-devel package or someth?
:o it's building
yes, there's a python-dev package you'll need
yea i got it
crazygmr101@crazygmr101:~/ansura/website$ uwsgi --http :9090 --wsgi-file main.py
uwsgi: option '--http' is ambiguous; possibilities: '--http-socket' '--http-socket-modifier1' '--http-socket-modifier2' '--https-socket' '--https-socket-modifier1' '--https-socket-modifier2'
getopt_long() error
use --http-socket
uwsgi --help
ll, however you ran that
is right
You can't bind to ports < 1024 if you're not root
which is expected
apache should be handling that for you
probably
i was trying to bind to 9090 tho
Well, you can see in the error message flask is trying to bind ssl to port 443
do you have an ssl package enabled?
shouldn't have that if you're using a proxy server
yea, it was the only thing that would get uwsgi to work
apt-get install libssl-dev
pip install uwsgi -I --no-cache-dir
found this on SO
so
ok
i see it loading flask, then dying
(also i forgot, in my messing, i tried to run flask with SSL earlier)
which did work, to run flask standalone
right, so the deal here is it's unable to find the stuff that tells it what to run
normally there's an ini file but you SHOULD be able to just point it at your file with a wsgi app in it
import sys
import importlib
sys.path.insert(0, "/home/crazygmr101/ansura/website")
from main import app as application
thats my ansurasite.wsgi
in same dir as main.py
What's the command you're using?
i tried uwsgi --http-socket :9090 --wsgi-file ansurasite.wsgi
not sure how else i'd 'point' it at the wsgi
Well, we can see here it's looking for "/ansura/website/uwsgi" despite you passing in ansurasite.wsgi
those are quite different
/ansura/website/uwsgi also doesnt exist
Try specifically doing ansurasite/wsgi.py
uh no
also this works
should i try enabling ssl or
ah oki
Now that you've got wsgi working you should be able to use a unix socket and point apache at it
" !!! no internal routing support, rebuild with pcre support !!!" does this matter
o
ok
nope
why's it looking for uwsgi again
cuz i removed the :app presumably
" !!! no internal routing support, rebuild with pcre support !!!" does this matter
@native tide ^^ and this?
so.. what do i do :S
Here's something straight from the wsgi docs that should work:
uwsgi --socket 127.0.0.1:3031 --wsgi-file myflaskapp.py --callable app --processes 4 --threads 2 --stats 127.0.0.1:9191
Well, of course change myflaskapp to your main file
import flask
app = Flask()
@app.route("/")
def do():
return "Test"
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello, World, from Flask!"
something li- yeup
Yeah
