mardi 28 mai 2019

how to run a python file on a django website

I (a django beginner) am making a website (http://tijmenmeijer.pythonanywhere.com/articles/) with django. I created a python file and I'd like to run that file on my website.. how to do that?

import requests
import pygame,sys
pygame.init()

run = True
while run:


headers = {'Referer' : 'https://www.windguru.cz/station/219'}    
r = requests.get(' https://www.windguru.cz/int/iapi.php?q=station_data_current&id_station=219&date_format=Y-m-d%20H%3Ai%3As%20T&_mha=f4d18b6c', headers = headers).json()


maxwind = r['wind_max']
minwind = r['wind_min']
avgwind = r['wind_avg']
temp = r['temperature']
direction = r['wind_direction']
date = r['datetime']


for event in pygame.event.get():
    if event.type == pygame.QUIT:
        quit()

screen = pygame.display.set_mode((300,100))
screen.fill((100,255,255))

sys_font = pygame.font.SysFont("None",23)
render = sys_font.render(str(avgwind) + str(' knopen -- ') + str(maxwind) + str(' max -- ') + str(minwind) + str(' min'), 0,(0,0,0))
screen.blit(render, (35,10))


pygame.display.update()




Aucun commentaire:

Enregistrer un commentaire